--- a/src/HTTPServer.h Thu Apr 07 21:06:37 2022 +0200
+++ b/src/HTTPServer.h Thu Apr 07 23:04:12 2022 +0200
@@ -17,6 +17,11 @@
#pragma once
+#include <vector>
+#include <string>
+#include <ctype.h>
+#include <memory>
+
namespace relpipe {
namespace tr {
namespace httpd {
@@ -31,11 +36,47 @@
public:
+
+ class Header {
+ public:
+ std::string name;
+ std::string value;
+ };
+
+ class Request {
+ public:
+ std::vector<Header> header;
+ std::string host;
+ std::string method;
+ std::string url;
+ std::string body;
+ };
+
+ class Response {
+ public:
+ std::vector<Header> header;
+ uint16_t code;
+ std::string body;
+ };
+
+ class RequestHandler {
+ public:
+
+ virtual const Response handle(const Request& request);
+ };
+
+ class Options {
+ public:
+ uint16_t tcpPort = 8080;
+ };
+
virtual ~HTTPServer();
HTTPServer(const HTTPServer&) = delete;
HTTPServer& operator=(const HTTPServer&) = delete;
- static HTTPServer* create();
+ void setRequestHandler(std::shared_ptr<RequestHandler> handler);
+
+ static HTTPServer* create(Options options);
};