30#if !defined(FLECS_OS_API_IMPL) && !defined(FLECS_NO_OS_API_IMPL)
31#define FLECS_OS_API_IMPL
38#define ECS_HTTP_HEADER_COUNT_MAX (32)
41#define ECS_HTTP_QUERY_PARAM_COUNT_MAX (32)
72 EcsHttpMethodUnsupported
99#define ECS_HTTP_REPLY_INIT \
100 (ecs_http_reply_t){200, ECS_STRBUF_INIT, "OK", "application/json", ECS_STRBUF_INIT}
int64_t ecs_http_request_not_handled_count
Total number of HTTP requests with an unknown endpoint.
FLECS_API const char * ecs_http_get_param(const ecs_http_request_t *req, const char *name)
Find query parameter in request.
int64_t ecs_http_request_invalid_count
Total number of invalid HTTP requests.
int64_t ecs_http_send_error_count
Total number of HTTP replies that failed to send.
bool(* ecs_http_reply_action_t)(const ecs_http_request_t *request, ecs_http_reply_t *reply, void *ctx)
Request callback.
int64_t ecs_http_request_received_count
Total number of HTTP requests received.
FLECS_API int ecs_http_server_start(ecs_http_server_t *server)
Start server.
FLECS_API void ecs_http_server_stop(ecs_http_server_t *server)
Stop server.
int64_t ecs_http_busy_count
Total number of HTTP busy replies.
int64_t ecs_http_request_handled_error_count
Total number of HTTP requests with errors.
FLECS_API int ecs_http_server_request(ecs_http_server_t *srv, const char *method, const char *req, ecs_http_reply_t *reply_out)
Convenience wrapper around ecs_http_server_http_request().
FLECS_API void ecs_http_server_dequeue(ecs_http_server_t *server, ecs_ftime_t delta_time)
Process server requests.
int64_t ecs_http_request_preflight_count
Total number of preflight HTTP requests received.
FLECS_API const char * ecs_http_get_header(const ecs_http_request_t *req, const char *name)
Find header in request.
#define ECS_HTTP_HEADER_COUNT_MAX
Maximum number of headers in request.
ecs_http_method_t
Supported request methods.
int64_t ecs_http_send_ok_count
Total number of HTTP replies successfully sent.
FLECS_API void ecs_http_server_fini(ecs_http_server_t *server)
Destroy server.
struct ecs_http_server_t ecs_http_server_t
HTTP server.
FLECS_API ecs_http_server_t * ecs_http_server_init(const ecs_http_server_desc_t *desc)
Create server.
int64_t ecs_http_request_handled_ok_count
Total number of successful HTTP requests.
FLECS_API void * ecs_http_server_ctx(ecs_http_server_t *srv)
Get context provided in ecs_http_server_desc_t.
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.
#define ecs_ftime_t
Customizable precision for scalar time values.
A connection manages communication with the remote host.
Helper type used for headers & URL query parameters.
ecs_strbuf_t headers
default = ""
ecs_strbuf_t body
default = ""
const char * content_type
default = application/json
const char * status
default = OK
Used with ecs_http_server_init().
const char * ipaddr
Interface to listen on (optional)
int32_t send_queue_wait_ms
Send queue wait time when empty.
double cache_purge_timeout
Cache purge timeout (for purging cache entries)
void * ctx
Passed to callback (optional)
double cache_timeout
Cache invalidation timeout (0 disables caching)
ecs_http_reply_action_t callback
Function called for each request