HTTP router. More...
Typedefs | |
| typedef struct vtm_http_router | vtm_http_router |
Functions | |
| VTM_API vtm_http_router * | vtm_http_router_new (void) |
| VTM_API void | vtm_http_router_free (vtm_http_router *rtr) |
| VTM_API int | vtm_http_router_add_rt (vtm_http_router *rtr, const char *path, struct vtm_http_route *rt) |
| VTM_API int | vtm_http_router_static_rt (vtm_http_router *rtr, const char *path, vtm_http_static_rt_handle_fn fn) |
| VTM_API int | vtm_http_router_handle (vtm_http_router *rtr, struct vtm_http_ctx *ctx, struct vtm_http_req *req, vtm_http_res *res) |
| VTM_API vtm_http_router* vtm_http_router_new | ( | void | ) |
Creates a new router.
| VTM_API void vtm_http_router_free | ( | vtm_http_router * | rtr | ) |
Releases the router and all allocated resources.
This call also releases all routes that were added to the router. After this call the router pointer is no longer valid.
| rtr | the router that should be released |
| VTM_API int vtm_http_router_add_rt | ( | vtm_http_router * | rtr, |
| const char * | path, | ||
| struct vtm_http_route * | rt | ||
| ) |
Binds the route to the given URL path.
| rtr | the router where the route should be added |
| path | the URL path where the route should be bound to |
| rt | the route that should be added |
| VTM_API int vtm_http_router_static_rt | ( | vtm_http_router * | rtr, |
| const char * | path, | ||
| vtm_http_static_rt_handle_fn | fn | ||
| ) |
Adds a static route for the given path.
| rtr | the router where the route should be added |
| path | the URL path where the route should be bound to |
| fn | the callback function that should handle the route |
| VTM_API int vtm_http_router_handle | ( | vtm_http_router * | rtr, |
| struct vtm_http_ctx * | ctx, | ||
| struct vtm_http_req * | req, | ||
| vtm_http_res * | res | ||
| ) |
Lets the router handle a given request.
| rtr | the router that should handle a request |
| ctx | the context of the request |
| req | the request that should be handled |
| res | the response that musst be prepared |
1.8.8