![]() |
Flecs v4.1
A fast entity component system (ECS) for C & C++
|
HTTP addon. More...
Go to the source code of this file.
Classes | |
| struct | ecs_http_connection_t |
| A connection manages communication with the remote host. More... | |
| struct | ecs_http_key_value_t |
| Helper type used for headers and URL query parameters. More... | |
| struct | ecs_http_request_t |
| An HTTP request. More... | |
| struct | ecs_http_reply_t |
| An HTTP reply. More... | |
| struct | ecs_http_server_desc_t |
| Used with ecs_http_server_init(). More... | |
Macros | |
| #define | FLECS_HTTP_H |
| #define | ECS_HTTP_HEADER_COUNT_MAX (32) |
| Maximum number of headers in a request. | |
| #define | ECS_HTTP_QUERY_PARAM_COUNT_MAX (32) |
| Maximum number of query parameters in a request. | |
| #define | ECS_HTTP_REPLY_INIT (ecs_http_reply_t){200, ECS_STRBUF_INIT, "OK", "application/json", ECS_STRBUF_INIT} |
| Default initializer for ecs_http_reply_t. | |
Typedefs | |
| typedef struct ecs_http_server_t | ecs_http_server_t |
| HTTP server. | |
| typedef bool(* | ecs_http_reply_action_t) (const ecs_http_request_t *request, ecs_http_reply_t *reply, void *ctx) |
| Request callback. | |
Enumerations | |
| enum | ecs_http_method_t { EcsHttpGet , EcsHttpPost , EcsHttpPut , EcsHttpDelete , EcsHttpOptions , EcsHttpMethodUnsupported } |
| Supported request methods. More... | |
Functions | |
| FLECS_API ecs_http_server_t * | ecs_http_server_init (const ecs_http_server_desc_t *desc) |
| Create a server. | |
| FLECS_API void | ecs_http_server_fini (ecs_http_server_t *server) |
| Destroy a server. | |
| FLECS_API int | ecs_http_server_start (ecs_http_server_t *server) |
| Start a server. | |
| FLECS_API void | ecs_http_server_dequeue (ecs_http_server_t *server, ecs_ftime_t delta_time) |
| Process server requests. | |
| FLECS_API void | ecs_http_server_stop (ecs_http_server_t *server) |
| Stop a server. | |
| FLECS_API int | ecs_http_server_http_request (ecs_http_server_t *srv, const char *req, ecs_size_t len, ecs_http_reply_t *reply_out) |
| Emulate a request. | |
| FLECS_API int | ecs_http_server_request (ecs_http_server_t *srv, const char *method, const char *req, const char *body, ecs_http_reply_t *reply_out) |
| Convenience wrapper around ecs_http_server_http_request(). | |
| FLECS_API void * | ecs_http_server_ctx (ecs_http_server_t *srv) |
| Get context provided in ecs_http_server_desc_t. | |
| FLECS_API const char * | ecs_http_get_header (const ecs_http_request_t *req, const char *name) |
| Find a header in a request. | |
| FLECS_API const char * | ecs_http_get_param (const ecs_http_request_t *req, const char *name) |
| Find a query parameter in a request. | |
Variables | |
| int64_t | ecs_http_request_received_count |
| Global HTTP statistics. | |
| int64_t | ecs_http_request_invalid_count |
| Total number of invalid HTTP requests. | |
| int64_t | ecs_http_request_handled_ok_count |
| Total number of successful HTTP requests. | |
| int64_t | ecs_http_request_handled_error_count |
| Total number of HTTP requests with errors. | |
| int64_t | ecs_http_request_not_handled_count |
| Total number of HTTP requests with an unknown endpoint. | |
| int64_t | ecs_http_request_preflight_count |
| Total number of preflight HTTP requests received. | |
| int64_t | ecs_http_send_ok_count |
| Total number of HTTP replies successfully sent. | |
| int64_t | ecs_http_send_error_count |
| Total number of HTTP replies that failed to send. | |
| int64_t | ecs_http_busy_count |
| Total number of HTTP busy replies. | |
HTTP addon.
Minimalistic HTTP server that can receive and reply to simple HTTP requests. The main goal of this addon is to enable remotely connecting to a running Flecs application (for example, with a web-based UI) and request and visualize data from the ECS world.
Each server instance creates a single thread used for receiving requests. Received requests are enqueued and handled when the application calls ecs_http_server_dequeue(). This increases the latency of request handling vs. responding directly in the receive thread, but is better suited for retrieving data from ECS applications, as requests can be processed by an ECS system without having to lock the world.
This server is intended to be used in a development environment.
Definition in file http.h.