#pragma once #include #include #include #include #include "AsyncHTTPServer.hh" #include "ServerState.hh" class HTTPServer : public AsyncHTTPServer<> { public: explicit HTTPServer(std::shared_ptr state); HTTPServer(const HTTPServer&) = delete; HTTPServer(HTTPServer&&) = delete; HTTPServer& operator=(const HTTPServer&) = delete; HTTPServer& operator=(HTTPServer&&) = delete; virtual ~HTTPServer() = default; asio::awaitable send_rare_drop_notification(std::shared_ptr message); protected: struct RawResponse { std::string content_type; std::string data; }; std::shared_ptr state; std::unordered_set> rare_drop_subscribers; HTTPRouter>> router; void require_GET(const HTTPRequest& req); phosg::JSON require_POST(const HTTPRequest& req); virtual asio::awaitable> handle_request(std::shared_ptr c, HTTPRequest&& req); virtual asio::awaitable destroy_client(std::shared_ptr c); };