Class HttpServer
Defined in File http_server.hpp
-
class HttpServer
A simple HTTP server that listens for POST or PUT requests on a given endpoint.
The server is started on a separate thread(s) and will call the provided payload_parse_fn_t function when an incoming request is received. The payload_parse_fn_t function is expected to return a tuple conforming to
parse_status_t
(ex:std::make_tuple(200, "text/plain"s, "OK"s, nullptr)
).- Param payload_parse_fn
- Param bind_address
- Param port
- Param endpoint
- Param method
- Param num_threads
- Param max_payload_size
- Param request_timeout
The function that will be called when a POST request is received.
The address to bind the server to.
The port to bind the server to.
The endpoint to listen for POST requests on.
The HTTP method to listen for.
The number of threads to use for the server.
The maximum size in bytes of the payload that the server will accept in a single request.
The timeout for a request.
Public Functions
- HttpServer(std::vector<HttpEndpoint> endpoints, std::string bind_address = "127.0.0.1", unsigned short port = 8080, unsigned short num_threads = 1, std::size_t max_payload_size = DefaultMaxPayloadSize, std::chrono::seconds request_timeout = std::chrono::seconds(30))
- ~HttpServer()
- void start()
- void stop()
- bool is_running() const