Safe string type with helper methods.
struct cwist_mux_route cwist_mux_route
bool cwist_mux_serve(cwist_mux_router *router, cwist_http_request *req, cwist_http_response *res)
Dispatch a request.
void(* cwist_http_handler_func)(cwist_http_request *req, cwist_http_response *res)
void cwist_mux_handle(cwist_mux_router *router, cwist_http_method_t method, const char *path, cwist_http_handler_func handler)
Register a route handler.
cwist_mux_router * cwist_mux_router_create(void)
Create a new router.
struct cwist_mux_router cwist_mux_router
void cwist_mux_router_destroy(cwist_mux_router *router)
Destroy a router.
HTTP Protocol Definitions and Helpers.
void cwist_mux_route_use(cwist_mux_route *route, cwist_middleware_func mw)
Attach middleware to a specific route.
void cwist_mux_group_destroy(cwist_mux_group *group)
Destroy a route group.
void(* cwist_http_handler_func)(cwist_http_request *req, cwist_http_response *res)
cwist_mux_route * cwist_mux_find_route(cwist_mux_router *router, cwist_http_method_t method, const char *path)
Find a matching route.
cwist_mux_group * cwist_mux_group_create(cwist_mux_router *router, const char *prefix)
Create a route group with a path prefix.
void cwist_mux_group_handle(cwist_mux_group *group, cwist_http_method_t method, const char *path, cwist_http_handler_func handler)
Register a handler inside a group.
HTTP Response Object. Supports standard string body or Zero-Copy pointer body.
cwist_mux_router * router
cwist_middleware_func func
struct cwist_mux_middleware_node * next
struct cwist_mux_route * next
Used for global cleanup.
cwist_http_handler_func handler
bool is_parametric
True if path contains parameters like :id.
bool is_wildcard
True if path ends with *.
struct cwist_mux_route * param_next
Used for parametric routes.
cwist_http_method_t method
struct cwist_mux_route * bucket_next
Used for exact matches.
cwist_mux_middleware_node * middleware
Per-route middleware chain.
cwist_mux_route * param_routes
Head of the parametric routes list.
cwist_mux_route ** buckets
cwist_mux_route * wildcard_routes
Head of wildcard routes list.
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.