Data Fields | |
void(* | server_ready )(vtm_http_srv *srv, struct vtm_http_srv_opts *opts) |
void(* | worker_init )(struct vtm_http_ctx *ctx) |
void(* | worker_end )(struct vtm_http_ctx *ctx) |
void(* | http_request )(struct vtm_http_ctx *ctx, struct vtm_http_req *req, vtm_http_res *res) |
void(* | ws_connect )(struct vtm_http_ctx *ctx, vtm_ws_con *con) |
void(* | ws_message )(struct vtm_http_ctx *ctx, struct vtm_ws_msg *msg) |
void(* | ws_close )(struct vtm_http_ctx *ctx, vtm_ws_con *con) |
Holds the user defined callbacks for an HTTP server.
When a specific callback is not needed, then is MUST be set to NULL.
Unless otherwise stated each callback function is called from a worker-thread. When the server runs in single-threaded mode, the functions are called from the main thread that started the server.
void(* vtm_http_srv_cbs::server_ready)(vtm_http_srv *srv, struct vtm_http_srv_opts *opts) |
This function is called when the HTTP server was successfully created and is ready to accept incoming connections.
The function is called in the same thread that called vtm_http_srv_run()
srv | the server that is ready |
opts | the options with which the server was startet |
void(* vtm_http_srv_cbs::worker_init)(struct vtm_http_ctx *ctx) |
This function is is called during startup phase of the HTTP server for each worker thread.
srv | the server |
ctx | the context with the global HTTP memory object and the per-thread dataset |
void(* vtm_http_srv_cbs::worker_end)(struct vtm_http_ctx *ctx) |
This function is called during shutdown phase of the HTTP server for each worker thread.
srv | the server |
ctx | the context with the global HTTP memory object and the per-thread dataset |
void(* vtm_http_srv_cbs::http_request)(struct vtm_http_ctx *ctx, struct vtm_http_req *req, vtm_http_res *res) |
Called for each HTTP request.
ctx | the context |
req | the request details |
res | response handle for sending back the HTTP response |
void(* vtm_http_srv_cbs::ws_connect)(struct vtm_http_ctx *ctx, vtm_ws_con *con) |
Called for each new WebSocket connection.
ctx | the context |
con | the client connection object |
void(* vtm_http_srv_cbs::ws_message)(struct vtm_http_ctx *ctx, struct vtm_ws_msg *msg) |
Called when a new WebSocket message was received.
ctx | the context |
msg | the received message |
void(* vtm_http_srv_cbs::ws_close)(struct vtm_http_ctx *ctx, vtm_ws_con *con) |
Called when a WebSocket connection was closed.
ctx | the context |
con | the connection that was closed |