1#ifndef TENDUKE_HTTP_SERVER_ABSTRACTHTTPSERVER_H
2#define TENDUKE_HTTP_SERVER_ABSTRACTHTTPSERVER_H
4#include "./HTTPServer.h"
5#include "./HTTPRequest.h"
6#include "./HTTPResponse.h"
7#include "./HTTPRequestHandler.h"
14namespace tenduke {
namespace http {
namespace server {
34 const std::string &route,
35 const std::shared_ptr<tenduke::http::server::HTTPRequestHandler> &handler
42 std::uint16_t
getPort()
override;
43 void start()
override;
68 std::map<std::string, std::shared_ptr<tenduke::http::server::HTTPRequestHandler>>
routes;
71 std::unique_ptr<tenduke::osa::Socket> socket;
Abstract base class of a HTTP server.
Definition AbstractHTTPServer.h:20
HTTPRequest parseRequest(const std::shared_ptr< tenduke::osa::Socket > &requestSocket) const
Parses HTTP request from socket.
Definition AbstractHTTPServer.cpp:65
void handleRequest(tenduke::http::server::HTTPRequest request, tenduke::http::server::HTTPResponse response) const
Handles HTTP request.
Definition AbstractHTTPServer.cpp:118
void stop() override
Stops the server.
Definition AbstractHTTPServer.cpp:58
std::uint16_t getPort() override
Returns the port where this simple server is listening.
Definition AbstractHTTPServer.cpp:145
std::atomic_bool running
Flag to indicate if the server is running.
Definition AbstractHTTPServer.h:66
void start() override
Starts the server.
Definition AbstractHTTPServer.cpp:26
void registerRoute(const std::string &route, const std::shared_ptr< tenduke::http::server::HTTPRequestHandler > &handler)
Register a route.
Definition AbstractHTTPServer.cpp:151
std::map< std::string, std::shared_ptr< tenduke::http::server::HTTPRequestHandler > > routes
Routes.
Definition AbstractHTTPServer.h:68
A HTTP-request parsed by HTTP server.
Definition HTTPRequest.h:17
HTTP-response to be returned by a HTTP server.
Definition HTTPResponse.h:15
Interface for simple HTTPServer.
Definition HTTPServer.h:17
Root for classes, functions and globals of 10Duke C++ Client.
Definition APIRequest.h:4