#include "Helpers.hpp" #include "Main.hpp" void HTTPrequest::start() { // Possible Logging here processHTTPHeader(); } void HTTPrequest::processRequest() { // // This is where we will process requests // uint64_t pathHash = Helpers::Pathhash(requestPath); // This is very much temp if (requestType == "POST") { switch (pathHash) { case "/upload"_hash: writeData(Helpers::GenerateResponse("501 Not Implemented", "text/text", "This path is not implemented yet!")); return; } return; } // This can be further refactored to just "File send" switch (pathHash) { case "/"_hash: writeData(Helpers::GenerateResponse("200 OK", "text/html", Helpers::ReadFile("www/index.html"))); return; default: writeData(Helpers::GenerateResponse("404 Not Found", "text/html", "Could not find that file!!")); return; } } void HTTPrequest::writeData(std::string data) { // // Response here // asio::async_write(sock, asio::buffer(data), [](std::error_code, std::size_t) {}); } // ================= CLASS HANDLING SPECIFIC ================= HTTPrequest::HTTPrequest(asio::io_context &context) : sock(context) {} asio::ip::tcp::socket &HTTPrequest::socket() { return sock; } HTTPrequest::HTTPrequest_ptr HTTPrequest::create(asio::io_context &context) { return HTTPrequest_ptr(new HTTPrequest(context)); }