10Duke Enterprise C++ Client
|
#include <AbstractHTTPServer.h>
Abstract base class of a HTTP server.
Public Member Functions | |
AbstractHTTPServer (std::unique_ptr< tenduke::osa::Socket > socket) | |
Constructs new instance. | |
void | registerRoute (const std::string &route, const std::shared_ptr< tenduke::http::server::HTTPRequestHandler > &handler) |
Register a route. | |
std::uint16_t | getPort () override |
Returns the port where this simple server is listening. | |
void | start () override |
Starts the server. | |
void | stop () override |
Stops the server. | |
Protected Member Functions | |
HTTPRequest | parseRequest (const std::shared_ptr< tenduke::osa::Socket > &requestSocket) const |
Parses HTTP request from socket. | |
void | handleRequest (tenduke::http::server::HTTPRequest request, tenduke::http::server::HTTPResponse response) const |
Handles HTTP request. | |
Protected Attributes | |
std::atomic_bool | running |
Flag to indicate if the server is running. | |
std::map< std::string, std::shared_ptr< tenduke::http::server::HTTPRequestHandler > > | routes |
Routes. | |
|
explicit |
Constructs new instance.
socket | socket where this server is listening in |
|
overridevirtual |
Returns the port where this simple server is listening.
Implements tenduke::http::server::HTTPServer.
Reimplemented in tenduke::test::fakes::FakeHttpServer.
|
protected |
Handles HTTP request.
request | - |
response | - |
|
protected |
Parses HTTP request from socket.
requestSocket | - |
void tenduke::http::server::AbstractHTTPServer::registerRoute | ( | const std::string & | route, |
const std::shared_ptr< tenduke::http::server::HTTPRequestHandler > & | handler | ||
) |
Register a route.
route | - |
handler | - |
|
overridevirtual |
Starts the server.
Implements tenduke::http::server::HTTPServer.
Reimplemented in tenduke::test::fakes::FakeHttpServer.
|
overridevirtual |
Stops the server.
Implements tenduke::http::server::HTTPServer.