Class HttpServer

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

The function that will be called when a POST request is received.

Param bind_address

The address to bind the server to.

Param port

The port to bind the server to.

Param endpoint

The endpoint to listen for POST requests on.

Param method

The HTTP method to listen for.

Param num_threads

The number of threads to use for the server.

Param max_payload_size

The maximum size in bytes of the payload that the server will accept in a single request.

Param request_timeout

The timeout for a request.

Public Functions

HttpServer(payload_parse_fn_t payload_parse_fn, std::string bind_address = "127.0.0.1", unsigned short port = 8080, std::string endpoint = "/message", std::string method = "POST", 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

Previous Class GRPCDataLoader
Next Class HttpServerSourceStage
© Copyright 2024, NVIDIA. Last updated on Apr 25, 2024.