cwist
Modern C web framework with libttak runtime
Loading...
Searching...
No Matches
app.h
Go to the documentation of this file.
1
6#ifndef __CWIST_APP_H__
7#define __CWIST_APP_H__
8
11#include <cwist/core/db/sql.h>
12#include <cwist/core/db/pool.h>
14#include <cwist/net/grpc/grpc.h>
17#include <cwist/core/macros.h>
19#include <ttak/mem_tree/mem_tree.h>
20
23
24/* Forward declaration for auto-mounted RDBMS runtime */
26
33
43typedef void (*cwist_handler_ex_func)(void *user_ctx, cwist_http_request *req,
45
50typedef void (*cwist_handler_ctx_destroy_func)(void *user_ctx);
51
57
62 cwist_http_status_t status);
63
72 void *stream);
73
79
87
95
102
110bool cwist_rdbms_mount_runtime(cwist_app *app, cwist_rdbms_provider_t provider, int port);
111
116 cwist_handler_func next);
117
125 cwist_handler_func next, void *user_ctx);
126
128typedef void (*cwist_middleware_ctx_destroy_func)(void *user_ctx);
129
131
143
148
224
230typedef struct cwist_file_t {
231 char *path;
232 char *fs_path;
233 void *data;
234 size_t size;
235 time_t last_mod;
236 char etag[40];
237 char last_mod_hdr[30];
238 ttak_mem_node_t *node;
240
263
271
278void cwist_app_enable_swagger(cwist_app *app, const char *mount_path,
279 const char *openapi_json_path);
280
286
292void cwist_app_set_max_memspace(cwist_app *app, size_t size);
293
297
315 cwist_middleware_func_ex mw_ex, void *user_ctx,
333void cwist_app_configure_bdr(cwist_app *app, size_t max_bytes, time_t max_entry_age_sec,
334 uint64_t revalidate_hits);
335
336cwist_error_t cwist_app_use_https(cwist_app *app, const char *cert_path, const char *key_path);
337
360cwist_error_t cwist_app_reload_tls(cwist_app *app, const char *cert_path, const char *key_path);
363
371
380
392
398void cwist_app_use_pqc_layer(cwist_app *app, bool enabled);
399
406void cwist_app_set_tls_groups(cwist_app *app, const char *groups);
407
408cwist_error_t cwist_app_use_db(cwist_app *app, const char *db_path);
409cwist_error_t cwist_app_use_nuke_db(cwist_app *app, const char *db_path, int sync_interval_ms);
411
418cwist_error_t cwist_app_use_db_pool(cwist_app *app, const char *db_path, size_t max_conns);
419
424
432cwist_error_t cwist_app_use_redis(cwist_app *app, const char *host, int port, size_t max_conns);
433
438
445cwist_error_t cwist_app_use_scheduler(cwist_app *app, size_t worker_count, size_t queue_capacity);
446
451
462bool cwist_app_auto_rdbms(cwist_app *app, int port);
463
464#define cwist_use_https2(enabled) cwist_app_use_https2((app), (enabled))
465#define cwist_use_https3(enabled) cwist_app_use_https3((app), (enabled))
466#define cwist_use_http2(enabled) cwist_app_use_http2((app), (enabled))
467#define cwist_use_http3(enabled) cwist_app_use_http3((app), (enabled))
468
474void cwist_app_get(cwist_app *app, const char *path, cwist_handler_func handler);
475void cwist_app_post(cwist_app *app, const char *path, cwist_handler_func handler);
476void cwist_app_put(cwist_app *app, const char *path, cwist_handler_func handler);
477void cwist_app_delete(cwist_app *app, const char *path, cwist_handler_func handler);
478void cwist_app_patch(cwist_app *app, const char *path, cwist_handler_func handler);
479void cwist_app_ws(cwist_app *app, const char *path, cwist_ws_handler_func handler);
480
507cwist_error_t cwist_app_get_ex(cwist_app *app, const char *path, cwist_handler_ex_func handler,
508 void *user_ctx, cwist_handler_ctx_destroy_func destroy);
510cwist_error_t cwist_app_post_ex(cwist_app *app, const char *path, cwist_handler_ex_func handler,
511 void *user_ctx, cwist_handler_ctx_destroy_func destroy);
513cwist_error_t cwist_app_put_ex(cwist_app *app, const char *path, cwist_handler_ex_func handler,
514 void *user_ctx, cwist_handler_ctx_destroy_func destroy);
517 void *user_ctx, cwist_handler_ctx_destroy_func destroy);
520 void *user_ctx, cwist_handler_ctx_destroy_func destroy);
521
530void cwist_app_ws_async(cwist_app *app, const char *path, cwist_ws_on_message_t on_message,
531 void *user_data);
532void cwist_app_get_opt(cwist_app *app, const char *path, cwist_handler_func handler,
534void cwist_app_post_opt(cwist_app *app, const char *path, cwist_handler_func handler,
536void cwist_app_put_opt(cwist_app *app, const char *path, cwist_handler_func handler,
538void cwist_app_delete_opt(cwist_app *app, const char *path, cwist_handler_func handler,
540void cwist_app_patch_opt(cwist_app *app, const char *path, cwist_handler_func handler,
542void cwist_app_ws_opt(cwist_app *app, const char *path, cwist_ws_handler_func handler,
544
547
548void cwist_app_get_named(cwist_app *app, const char *path, const char *name,
549 cwist_handler_func handler);
550void cwist_app_post_named(cwist_app *app, const char *path, const char *name,
551 cwist_handler_func handler);
552void cwist_app_put_named(cwist_app *app, const char *path, const char *name,
553 cwist_handler_func handler);
554void cwist_app_delete_named(cwist_app *app, const char *path, const char *name,
555 cwist_handler_func handler);
556void cwist_app_patch_named(cwist_app *app, const char *path, const char *name,
557 cwist_handler_func handler);
558char *cwist_url_for(cwist_app *app, const char *name, cwist_query_map *params);
559
568cwist_error_t cwist_app_static(cwist_app *app, const char *url_prefix, const char *directory);
569
579cwist_error_t cwist_app_static_with_cache(cwist_app *app, const char *url_prefix,
580 const char *directory, const char *cache_control);
586#ifndef CWIST_MULTIPORT_MAX_PORTS
587#define CWIST_MULTIPORT_MAX_PORTS 64
588#endif
589
598
605cwist_multiport_t cwist_create_multiport_from_array(const unsigned short *ports, size_t count);
606
611#define cwist_create_multiport(ports) \
612 cwist_create_multiport_from_array((ports), sizeof(ports) / sizeof((ports)[0]))
613
614void cwist_app_http_handler(int client_fd, void *ctx);
616
628void cwist_apply_profile(void);
629
638int cwist_app_listen(cwist_app *app, int port);
639
650int cwist_app_listen_ex(cwist_app *app, int port, int workers_override, int c1m_override);
651
659int cwist_app_multiport(cwist_app **app_ref, unsigned short public_port, cwist_multiport_t ports);
660
668cwist_app *cwist_multiport_get_app(cwist_app **app_ref, unsigned short port);
676
689int cwist_app_dispatch_memory(cwist_app *app, const char *req_buf, size_t req_len, char **res_buf,
690 size_t *res_len);
691
708typedef int (*cwist_stream_write_fn)(void *ctx, const char *data, size_t len);
709
711#define CWIST_STREAM_CHUNK (64 * 1024)
712
724int cwist_app_dispatch_stream(cwist_app *app, const char *req_buf, size_t req_len,
725 cwist_stream_write_fn write_fn, void *write_ctx);
726
731typedef struct cwist_stream_req cwist_stream_req_t;
732
740cwist_stream_req_t *cwist_stream_req_begin(const char *head, size_t head_len);
741
748int cwist_stream_req_feed(cwist_stream_req_t *req, const char *chunk, size_t len);
749
756
764 cwist_stream_write_fn write_fn, void *write_ctx);
765
766#endif
Auto-Caching Layer for repetitive requests.
Database operations wrapper (SQLite3).
Convenience size-conversion and utility macros shared across CWIST.
Minimal in-tree Redis client (RESP2) with connection pooling.
struct cwist_redis_pool cwist_redis_pool_t
Redis connection pool handle.
Definition cwist_redis.h:24
uint32_t cwist_endpoint_opt_t
Bitmask type controlling endpoint behavior.
gRPC over HTTP/2 helpers for CWIST.
cwist_http_status_t
Definition http.h:27
HTTP Protocol Definitions and Helpers.
cwist_async_action_t
Definition http.h:447
HTTPS/TLS wrapper interface.
WebSocket upgrade and frame handling.
size_t head
Definition otel.c:57
size_t count
Definition otel.c:58
SQLite connection pool for CWIST.
struct cwist_db_pool cwist_db_pool_t
Opaque database connection pool handle.
Definition pool.h:21
Background job scheduler / delayed task queue for CWIST.
struct cwist_scheduler cwist_scheduler_t
Opaque background job scheduler handle.
Definition scheduler.h:21
Main Application Context.
Definition app.h:155
bool nuke_enabled
True when NUKE DB integration is active.
Definition app.h:181
bool use_https2
TLS HTTP/2 (h2)
Definition app.h:160
void * redis_pool
Redis connection pool (when enabled).
Definition app.h:213
bool use_ssl
Definition app.h:157
size_t max_mem_space
Max memory space for static file pool (0 = auto-detected * 2)
Definition app.h:184
void * scheduler
Background job scheduler (when enabled).
Definition app.h:216
cwist_webtransport_handler_func wt_handler
WebTransport session handler.
Definition app.h:200
cwist_error_handler_func error_handler
Global fallback error handler.
Definition app.h:171
int session_max_age
Session cookie max-age in seconds.
Definition app.h:207
cwist_https_context * ssl_ctx
SSL context when TLS is enabled.
Definition app.h:177
struct cwist_fix_server_mem * mem_manager
Memory manager for static asset caching and hot-reloading.
Definition app.h:186
char * session_secret
Session signing secret (HMAC-SHA256).
Definition app.h:203
bool use_http2
Cleartext HTTP/2 (h2c)
Definition app.h:158
cwist_error_handler_entry * error_handlers
Per-status-code error handlers.
Definition app.h:172
bool use_http3
Ephemeral (Zero-config) HTTP/3.
Definition app.h:159
cwist_bdr_t * bdr_ctx
Legacy standalone BDR storage; never replayed by HTTP dispatch.
Definition app.h:189
cwist_route_table * router
Router definition.
Definition app.h:168
cwist_db * db
Shared database handle.
Definition app.h:179
char * session_name
Session cookie name.
Definition app.h:205
char * key_path
Definition app.h:163
cwist_https_request_handler_func https_request_handler
Definition app.h:164
char * tls_groups
Explicit TLS groups override (NULL = automatic)
Definition app.h:197
void * db_pool
Database connection pool (when enabled).
Definition app.h:210
char * db_path
Database path (if set).
Definition app.h:180
int port
Definition app.h:156
bool use_https3
TLS HTTP/3.
Definition app.h:161
struct cwist_rdbms_runtime * rdbms
Mounted RDBMS runtime (auto-detected PostgreSQL/MySQL/MariaDB)
Definition app.h:192
struct cwist_config * config
Application configuration.
Definition app.h:174
bool pqc_layer_enabled
PQC Layer enabled flag.
Definition app.h:195
struct cwist_http3_context * h3_ctx
HTTP/3 QUIC Context.
Definition app.h:178
char * cert_path
Definition app.h:162
cwist_middleware_node * middlewares
Head of the middleware chain.
Definition app.h:166
cwist_static_dir * static_dirs
Static directory mappings.
Definition app.h:169
void * grpc_routes
Unary gRPC route registry.
Definition app.h:219
struct cwist_logger * logger
Application logger.
Definition app.h:175
void * assets
Content-hashed in-memory assets (see <cwist/sys/app/assets.h>).
Definition app.h:222
Big Dumb Reply Context. Lock-free read/learn paths; the mutex only serializes janitor work (sweep/tri...
Wrapper for Database Operations. Currently uses SQLite3.
Definition sql.h:21
Definition app.h:74
cwist_error_handler_func handler
Definition app.h:76
struct cwist_error_handler_entry * next
Definition app.h:77
cwist_http_status_t status_code
Definition app.h:75
Integrated error structure used throughout the system.
Definition cwist_err.h:72
Represents a file loaded into the fixed memory pool.
Definition app.h:230
void * data
Pointer to memory-tracked file contents.
Definition app.h:233
size_t size
Size of the file in bytes.
Definition app.h:234
char etag[40]
Precomputed ETag for conditional requests.
Definition app.h:236
ttak_mem_node_t * node
Tracking node for libttak lifecycle.
Definition app.h:238
time_t last_mod
Last modification time.
Definition app.h:235
char * fs_path
Full filesystem path.
Definition app.h:232
char * path
Relative path (URL path)
Definition app.h:231
char last_mod_hdr[30]
Precomputed HTTP-date (29 chars + NUL)
Definition app.h:237
Fixed Server Memory Manager.
Definition app.h:247
pthread_mutex_t lock
Definition app.h:258
int check_interval_ms
Definition app.h:261
size_t files_capacity
Capacity of the files array.
Definition app.h:253
ttak_mem_tree_t file_tree
Lifetime tracking tree for file buffers.
Definition app.h:256
size_t current_used
Bytes accounted for by active files.
Definition app.h:249
bool watcher_running
Definition app.h:260
uint64_t retire_grace_ns
Delay before recycling replaced buffers.
Definition app.h:255
cwist_file_t * files
Array of tracked files.
Definition app.h:251
pthread_t watcher_thread
Definition app.h:259
size_t file_count
Definition app.h:252
size_t total_capacity
Total capacity (defaults to sum of files * 2)
Definition app.h:248
HTTP/3 server context encapsulating lsquic/BoringSSL settings.
Definition http3.h:35
HTTP Response Object. Supports standard string body or Zero-Copy pointer body.
Definition http.h:82
Linked list node for middleware chain.
Definition app.h:135
struct cwist_middleware_node * next
Definition app.h:141
cwist_middleware_ctx_destroy_func destroy
Definition app.h:139
cwist_middleware_func_ex func_ex
Definition app.h:137
cwist_middleware_func func
Definition app.h:136
Counted multiport descriptor created from a normal C array.
Definition app.h:593
bool valid
False when construction failed, e.g. too many ports.
Definition app.h:596
unsigned short ports[CWIST_MULTIPORT_MAX_PORTS]
Additional TCP ports.
Definition app.h:594
size_t count
Number of valid entries in ports.
Definition app.h:595
Mounted RDBMS runtime state.
Definition app.h:89
cwist_rdbms_provider_t provider
Definition app.h:90
char * host
Definition app.h:92
int cwist_app_listen(cwist_app *app, int port)
Serve app on port until SIGTERM, SIGINT or cwist_shutdown_request(); blocks the calling thread.
Definition app.c:4628
enum cwist_rdbms_provider cwist_rdbms_provider_t
RDBMS provider auto-detection result.
void cwist_app_delete(cwist_app *app, const char *path, cwist_handler_func handler)
Definition app.c:2275
cwist_rdbms_provider_t cwist_rdbms_probe_port(int port)
Probe a TCP port for an RDBMS wire protocol.
#define CWIST_MULTIPORT_MAX_PORTS
Definition app.h:587
void(* cwist_webtransport_handler_func)(cwist_http_request *req, cwist_http_response *res, void *stream)
Callback function type for handling WebTransport sessions over HTTP/3.
Definition app.h:71
void cwist_app_enable_metrics(cwist_app *app)
Definition app.c:2227
void cwist_app_enable_swagger(cwist_app *app, const char *mount_path, const char *openapi_json_path)
Enables embedded Swagger UI interactive documentation page.
Definition app.c:5051
cwist_error_t cwist_app_static_with_cache(cwist_app *app, const char *url_prefix, const char *directory, const char *cache_control)
Serves a directory of static files at a URL prefix with custom Cache-Control. Files are loaded into t...
Definition app.c:2103
cwist_error_t cwist_app_use_ex(cwist_app *app, cwist_middleware_func mw, cwist_middleware_func_ex mw_ex, void *user_ctx, cwist_middleware_ctx_destroy_func destroy)
Append an extended middleware to the application chain.
Definition app.c:1389
void cwist_app_put_named(cwist_app *app, const char *path, const char *name, cwist_handler_func handler)
Definition app.c:2288
cwist_app * cwist_multiport_get_app(cwist_app **app_ref, unsigned short port)
Detach one additional multiport port into its own tunable application.
void cwist_app_delete_opt(cwist_app *app, const char *path, cwist_handler_func handler, cwist_endpoint_opt_t opts)
Definition app.c:2385
cwist_stream_req_t * cwist_stream_req_begin(const char *head, size_t head_len)
Begin an incremental request: head is the serialized request line plus headers (everything up to and ...
Definition app.c:2600
void cwist_app_ws_opt(cwist_app *app, const char *path, cwist_ws_handler_func handler, cwist_endpoint_opt_t opts)
Register a WebSocket route with explicit endpoint options.
Definition app.c:2402
cwist_error_t cwist_app_use_nuke_db(cwist_app *app, const char *db_path, int sync_interval_ms)
Enable NUKE DB and fall back to standard SQLite when RAM bootstrap fails.
Definition app.c:1890
cwist_error_t cwist_app_static(cwist_app *app, const char *url_prefix, const char *directory)
Serves a directory of static files at a URL prefix. Files are loaded into the fixed memory pool for Z...
Definition app.c:2057
int cwist_stream_req_end(cwist_stream_req_t *req)
Declare the body complete. The fed byte count must equal the declared Content-Length (or both be zero...
Definition app.c:2646
void cwist_app_post_named(cwist_app *app, const char *path, const char *name, cwist_handler_func handler)
Definition app.c:2283
void(* cwist_handler_func)(cwist_http_request *req, cwist_http_response *res)
Function pointer type for HTTP route handlers.
Definition app.h:32
void cwist_app_get(cwist_app *app, const char *path, cwist_handler_func handler)
Registers a GET route handler.
Definition app.c:2216
void cwist_apply_profile(void)
Apply CWIST_PROFILE preset env-var defaults.
Definition app.c:4593
void cwist_app_http_handler(int client_fd, void *ctx)
Definition app.c:3506
char * cwist_url_for(cwist_app *app, const char *name, cwist_query_map *params)
Definition app.c:2475
void cwist_app_configure_bdr(cwist_app *app, size_t max_bytes, time_t max_entry_age_sec, uint64_t revalidate_hits)
Configures the Big Dumb Reply guardrails.
Definition app.c:1454
void(* cwist_error_handler_func)(cwist_http_request *req, cwist_http_response *res, cwist_http_status_t status)
Function pointer type for error handlers.
Definition app.h:61
cwist_db_pool_t * cwist_app_get_db_pool(cwist_app *app)
Return the application's database connection pool.
Definition app.c:1984
cwist_error_t cwist_app_reload_tls(cwist_app *app, const char *cert_path, const char *key_path)
Hot-reload the TLS certificate chain and key without restarting the listener.
Definition app.c:1691
void(* cwist_ws_handler_func)(cwist_websocket *ws)
Function pointer type for WebSocket handlers.
Definition app.h:56
void cwist_app_patch_named(cwist_app *app, const char *path, const char *name, cwist_handler_func handler)
Definition app.c:2298
cwist_error_t cwist_app_use_redis(cwist_app *app, const char *host, int port, size_t max_conns)
Configure a Redis connection pool for the application.
Definition app.c:1989
void cwist_app_post(cwist_app *app, const char *path, cwist_handler_func handler)
Register a POST handler with default endpoint options.
Definition app.c:2267
void(* cwist_middleware_func_ex)(cwist_http_request *req, cwist_http_response *res, cwist_handler_func next, void *user_ctx)
Extended middleware type that also receives a user context.
Definition app.h:124
cwist_error_t cwist_app_use_db(cwist_app *app, const char *db_path)
Open a SQLite database and attach it as the shared application handle.
Definition app.c:1851
void cwist_app_put(cwist_app *app, const char *path, cwist_handler_func handler)
Definition app.c:2271
int cwist_app_dispatch_stream(cwist_app *app, const char *req_buf, size_t req_len, cwist_stream_write_fn write_fn, void *write_ctx)
Like cwist_app_dispatch_memory(), but streams the serialized response through write_fn instead of ret...
Definition app.c:2668
void cwist_app_get_opt(cwist_app *app, const char *path, cwist_handler_func handler, cwist_endpoint_opt_t opts)
Register a GET handler with explicit endpoint options.
Definition app.c:2363
cwist_error_t cwist_app_post_ex(cwist_app *app, const char *path, cwist_handler_ex_func handler, void *user_ctx, cwist_handler_ctx_destroy_func destroy)
POST counterpart of cwist_app_get_ex().
Definition app.c:2185
void(* cwist_handler_ctx_destroy_func)(void *user_ctx)
Releases a route's user context once the route no longer needs it.
Definition app.h:50
cwist_error_t cwist_app_put_ex(cwist_app *app, const char *path, cwist_handler_ex_func handler, void *user_ctx, cwist_handler_ctx_destroy_func destroy)
PUT counterpart of cwist_app_get_ex().
Definition app.c:2190
void cwist_app_set_error_handler(cwist_app *app, cwist_error_handler_func handler)
Install a custom HTTP error callback.
Definition app.c:1411
void(* cwist_handler_ex_func)(void *user_ctx, cwist_http_request *req, cwist_http_response *res)
Route handler that also receives the context it was registered with.
Definition app.h:43
int(* cwist_stream_write_fn)(void *ctx, const char *data, size_t len)
Definition app.h:708
cwist_error_t cwist_app_get_ex(cwist_app *app, const char *path, cwist_handler_ex_func handler, void *user_ctx, cwist_handler_ctx_destroy_func destroy)
Registers a GET route whose handler receives a user context.
Definition app.c:2180
void cwist_app_post_opt(cwist_app *app, const char *path, cwist_handler_func handler, cwist_endpoint_opt_t opts)
Register a POST handler with explicit endpoint options.
Definition app.c:2375
void(* cwist_middleware_ctx_destroy_func)(void *user_ctx)
Destructor for a middleware user context.
Definition app.h:128
void cwist_app_set_tls_groups(cwist_app *app, const char *groups)
Override TLS groups explicitly.
Definition app.c:1749
void cwist_app_patch_opt(cwist_app *app, const char *path, cwist_handler_func handler, cwist_endpoint_opt_t opts)
Definition app.c:2390
bool cwist_app_auto_rdbms(cwist_app *app, int port)
Auto-detect and mount an RDBMS runtime by probing a TCP port.
void cwist_app_use(cwist_app *app, cwist_middleware_func mw)
Append a middleware callback to the application's execution chain.
Definition app.c:1376
cwist_error_t cwist_app_use_db_pool(cwist_app *app, const char *db_path, size_t max_conns)
Open a SQLite connection pool and attach it to the application.
Definition app.c:1958
void cwist_app_get_named(cwist_app *app, const char *path, const char *name, cwist_handler_func handler)
Definition app.c:2256
void cwist_app_destroy(cwist_app *app)
Destroys the application and frees all resources.
Definition app.c:1464
int cwist_stream_req_dispatch(cwist_stream_req_t *req, cwist_app *app, cwist_stream_write_fn write_fn, void *write_ctx)
Dispatch a completed incremental request with a streaming response. Takes ownership of req regardless...
Definition app.c:2653
void cwist_app_enable_healthz(cwist_app *app)
Definition app.c:2249
cwist_rdbms_provider
RDBMS provider auto-detection result.
Definition app.h:81
@ CWIST_RDBMS_POSTGRES
Definition app.h:83
@ CWIST_RDBMS_MARIADB
Definition app.h:85
@ CWIST_RDBMS_MYSQL
Definition app.h:84
@ CWIST_RDBMS_NONE
Definition app.h:82
void cwist_app_put_opt(cwist_app *app, const char *path, cwist_handler_func handler, cwist_endpoint_opt_t opts)
Definition app.c:2380
cwist_error_t cwist_app_use_http2(cwist_app *app, bool enabled)
Enable HTTP/2 cleartext (h2c) over standard TCP.
Definition app.c:1806
cwist_scheduler_t * cwist_app_get_scheduler(cwist_app *app)
Return the application's background job scheduler.
Definition app.c:2045
cwist_app * cwist_app_create(void)
Creates a new CWIST application instance.
Definition app.c:1292
struct cwist_route_table cwist_route_table
Definition app.h:144
cwist_error_t cwist_app_patch_ex(cwist_app *app, const char *path, cwist_handler_ex_func handler, void *user_ctx, cwist_handler_ctx_destroy_func destroy)
PATCH counterpart of cwist_app_get_ex().
Definition app.c:2200
cwist_error_t cwist_app_use_http3(cwist_app *app, bool enabled)
Enable HTTP/3 (QUIC) without manual SSL configuration. Auto-generates an ephemeral self-signed certif...
Definition app.c:1818
void cwist_app_use_webtransport(cwist_app *app, cwist_webtransport_handler_func handler)
Enable WebTransport over HTTP/3 on the application.
Definition app.c:1835
cwist_error_t cwist_app_use_https2(cwist_app *app, bool enabled)
Definition app.c:1760
void cwist_app_dispatch(cwist_app *app, cwist_http_request *req, cwist_http_response *res)
Dispatch a request internally through the app's router and middleware. Used by the test client and ad...
Definition app.c:2516
void(* cwist_middleware_func)(cwist_http_request *req, cwist_http_response *res, cwist_handler_func next)
Middleware type that receives req/res pair and the next stage in the chain.
Definition app.h:115
void cwist_app_ws_async(cwist_app *app, const char *path, cwist_ws_on_message_t on_message, void *user_data)
Register a callback-shaped non-blocking WebSocket endpoint (C1M mode).
Definition app.c:2330
cwist_async_action_t cwist_app_http_handler_async(int client_fd, cwist_http_async_conn_t *conn)
Definition app.c:3343
struct cwist_stream_req cwist_stream_req_t
Definition app.h:731
int cwist_app_listen_ex(cwist_app *app, int port, int workers_override, int c1m_override)
cwist_app_listen() with the worker count and server mode given explicitly.
Definition app.c:4636
cwist_multiport_t cwist_create_multiport_from_array(const unsigned short *ports, size_t count)
Create a counted multiport descriptor from an explicit pointer and length.
void cwist_app_patch(cwist_app *app, const char *path, cwist_handler_func handler)
Definition app.c:2279
void(* cwist_https_request_handler_func)(cwist_https_connection *conn, void *ctx)
Definition app.h:130
int cwist_stream_req_feed(cwist_stream_req_t *req, const char *chunk, size_t len)
Feed one body chunk. Chunks may be any size and may split anywhere; reassembly is the implementation'...
Definition app.c:2626
void cwist_app_register_error_handler(cwist_app *app, cwist_http_status_t status, cwist_error_handler_func handler)
Definition app.c:1415
void cwist_app_set_max_memspace(cwist_app *app, size_t size)
Sets the maximum memory space for the static file pool.
Definition app.c:1402
cwist_error_t cwist_app_delete_ex(cwist_app *app, const char *path, cwist_handler_ex_func handler, void *user_ctx, cwist_handler_ctx_destroy_func destroy)
DELETE counterpart of cwist_app_get_ex().
Definition app.c:2195
cwist_error_t cwist_app_use_scheduler(cwist_app *app, size_t worker_count, size_t queue_capacity)
Configure a background job scheduler for the application.
Definition app.c:2020
cwist_error_t cwist_app_use_https3(cwist_app *app, bool enabled)
Definition app.c:1783
void cwist_app_ws(cwist_app *app, const char *path, cwist_ws_handler_func handler)
Register a WebSocket upgrade endpoint with default options.
Definition app.c:2309
int cwist_app_dispatch_memory(cwist_app *app, const char *req_buf, size_t req_len, char **res_buf, size_t *res_len)
Run the full router/middleware/handler pipeline on a raw HTTP/1.x request held in a memory buffer,...
Definition app.c:2523
int cwist_app_multiport(cwist_app **app_ref, unsigned short public_port, cwist_multiport_t ports)
Start one app facade across a public port and counted backend port list.
bool cwist_rdbms_mount_runtime(cwist_app *app, cwist_rdbms_provider_t provider, int port)
Mount an RDBMS runtime for the given provider and port.
cwist_error_t cwist_app_use_https(cwist_app *app, const char *cert_path, const char *key_path)
Enable TLS for the application using the supplied certificate pair.
Definition app.c:1646
cwist_db * cwist_app_get_db(cwist_app *app)
Return the active shared database wrapper for the application.
Definition app.c:1948
void cwist_app_delete_named(cwist_app *app, const char *path, const char *name, cwist_handler_func handler)
Definition app.c:2293
void cwist_app_use_pqc_layer(cwist_app *app, bool enabled)
Enable Post-Quantum Cryptography (PQC) hybrid key exchange layer.
Definition app.c:1744
struct cwist_static_dir cwist_static_dir
Definition app.h:145
cwist_redis_pool_t * cwist_app_get_redis_pool(cwist_app *app)
Return the application's Redis connection pool.
Definition app.c:2015
Unified error code and type definitions for the CWIST system layer.
Reactor-driven, callback-shaped non-blocking WebSocket API (C1M mode).
void(* cwist_ws_on_message_t)(cwist_websocket_async *ws, cwist_ws_frame *frame, void *user_data)
Callback invoked for each complete WebSocket message on the C1M path.