forked from cat/WebBase
Start of map responses
This commit is contained in:
20
src/Main.hpp
20
src/Main.hpp
@@ -10,6 +10,7 @@
|
||||
#include <asio/placeholders.hpp>
|
||||
#include <asio/streambuf.hpp>
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
@@ -27,11 +28,16 @@ public:
|
||||
static HTTPrequest_ptr create(asio::io_context &context);
|
||||
|
||||
void start();
|
||||
void writeData(std::string data);
|
||||
|
||||
// Request itself
|
||||
std::string requestType, requestPath;
|
||||
std::unordered_map<std::string, std::string> headers, args;
|
||||
std::string bodyContent;
|
||||
|
||||
private:
|
||||
HTTPrequest(asio::io_context &context);
|
||||
void processRequest();
|
||||
void writeData(std::string data);
|
||||
|
||||
// Breaking Header to in lines
|
||||
void processHTTPHeader();
|
||||
@@ -41,11 +47,6 @@ private:
|
||||
std::size_t headerSize);
|
||||
void inline processBody();
|
||||
|
||||
// Request itself
|
||||
std::string requestType, requestPath;
|
||||
std::unordered_map<std::string, std::string> headers, args;
|
||||
std::string bodyContent;
|
||||
|
||||
// Networking
|
||||
asio::ip::tcp::socket sock;
|
||||
asio::streambuf buffer;
|
||||
@@ -58,6 +59,13 @@ public:
|
||||
|
||||
private:
|
||||
void begin();
|
||||
static void initResponses();
|
||||
|
||||
// Responses
|
||||
static std::unordered_map<
|
||||
std::string,
|
||||
std::unordered_map<std::string, std::function<void(HTTPrequest &self)>>>
|
||||
responseMethods;
|
||||
asio::io_context &io;
|
||||
asio::ip::tcp::acceptor accept;
|
||||
};
|
||||
|
Reference in New Issue
Block a user