|
cwist
Modern C web framework with libttak runtime
|
mux.h interface. More...

Go to the source code of this file.
Classes | |
| struct | cwist_mux_route |
| struct | cwist_mux_router |
Typedefs | |
| typedef void(* | cwist_http_handler_func) (cwist_http_request *req, cwist_http_response *res) |
| typedef struct cwist_mux_route | cwist_mux_route |
| typedef struct cwist_mux_router | cwist_mux_router |
Functions | |
Lifecycle | |
| cwist_mux_router * | cwist_mux_router_create (void) |
| Create a new router. | |
| void | cwist_mux_router_destroy (cwist_mux_router *router) |
| Destroy a router. | |
Route Management | |
| 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. | |
Dispatch | |
| bool | cwist_mux_serve (cwist_mux_router *router, cwist_http_request *req, cwist_http_response *res) |
| Dispatch a request. | |
mux.h interface.
Definition in file mux.h.
| typedef 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.
Register a route handler.
| router | Router that will own the route metadata. |
| method | HTTP method to match. |
| path | Exact request path to dispatch. |
| handler | Callback to invoke for a matching request. |
Definition at line 160 of file mux.c.
References cwist_mux_router::buckets, cap, cwist_alloc(), cwist_sstring_assign(), cwist_sstring_create(), cwist_mux_route::method, cwist_mux_route::param_next, cwist_mux_router::param_routes, cwist_mux_router::routes, and cwist_mux_router::wildcard_routes.
| cwist_mux_router * cwist_mux_router_create | ( | void | ) |
Create a new router.
Create a new router.
Definition at line 113 of file mux.c.
References cwist_mux_router::bucket_count, cwist_mux_router::buckets, cap, cwist_alloc(), cwist_alloc_array(), cwist_free(), CWIST_MUX_DEFAULT_BUCKETS, cwist_mux_router::param_routes, cwist_mux_router::routes, and cwist_mux_router::wildcard_routes.
| void cwist_mux_router_destroy | ( | cwist_mux_router * | router | ) |
Destroy a router.
Destroy a router.
| router | Router to destroy. NULL is ignored. |
Definition at line 134 of file mux.c.
References cwist_mux_router::buckets, cap, cwist_free(), cwist_sstring_destroy(), cwist_mux_route::next, cwist_mux_middleware_node::next, and cwist_mux_router::routes.
| bool cwist_mux_serve | ( | cwist_mux_router * | router, |
| cwist_http_request * | req, | ||
| cwist_http_response * | res | ||
| ) |
Dispatch a request.
Dispatch a request.
| router | Router containing registered exact-match handlers. |
| req | Parsed HTTP request with method and path information. |
| res | HTTP response object passed through to the matched handler. |
Definition at line 435 of file mux.c.
References cwist_mux_router::buckets, cap, cwist_query_map_destroy(), cwist_sstring::data, cwist_http_request::method, cwist_mux_router::param_routes, cwist_http_request::path, cwist_http_request::path_params, and cwist_mux_router::wildcard_routes.