6#ifndef __CWIST_MIDDLEWARE_H__
7#define __CWIST_MIDDLEWARE_H__
Minimal in-tree Redis client (RESP2) with connection pooling.
struct cwist_redis_pool cwist_redis_pool_t
Redis connection pool handle.
JWT (JSON Web Token) generation and verification.
struct cwist_jwt_claims cwist_jwt_claims
Opaque JWT claims object returned after successful verification.
cwist_log_format_t
Access log middleware output formats.
cwist_middleware_func cwist_mw_request_id(const char *header_name)
Request ID middleware factory.
cwist_middleware_func cwist_mw_rate_limit_ip(int requests_per_minute)
Fixed-window rate limiter middleware (per-IP).
cwist_middleware_func cwist_mw_access_log(cwist_log_format_t format)
Access log middleware factory.
Configuration for cwist_mw_otel_trace().
const char * service_name
Redis-backed rate limiter configuration. Strings are copied.
cwist_redis_pool_t * pool
Core Application Structure and Lifecycle Management.
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.
cwist_middleware_func cwist_mw_metrics(void)
Prometheus metrics collection middleware.
const char * cwist_mw_otel_get_trace_id(const cwist_http_request *req)
Trace id of the span cwist_mw_otel_trace() opened for req.
cwist_middleware_func cwist_mw_jwt_auth(const char *secret)
JWT authentication middleware factory.
const cwist_jwt_claims * cwist_mw_jwt_get_claims(const cwist_http_request *req)
Retrieve JWT claims stored by cwist_mw_jwt_auth from a request.
cwist_middleware_func cwist_mw_cors(void)
CORS middleware. Adds CORS headers and handles OPTIONS requests (returns 204).
cwist_middleware_func cwist_mw_rate_limit_ip_redis(const cwist_rate_limit_redis_cfg_t *cfg)
Shared per-IP 60-second window using one atomic Redis Lua command.
void cwist_mw_rate_limit_reset(void)
Reset the process-local IP table; Redis configs and keys are unchanged.
cwist_middleware_func cwist_mw_compress(size_t min_body_size)
Response compression middleware factory.
cwist_middleware_func cwist_mw_otel_trace(const cwist_otel_cfg_t *cfg)
OpenTelemetry tracing middleware.
Deterministic request firewall and output sanitization.