refactor(routing): moved some stuff, added some comments
This commit is contained in:
parent
cf4451740f
commit
115baecde8
6 changed files with 72 additions and 43 deletions
|
|
@ -89,4 +89,12 @@ uint64_t lnm_atoi(const char *s, size_t len);
|
|||
*/
|
||||
uint64_t lnm_digits(uint64_t num);
|
||||
|
||||
/**
|
||||
* Check whether the given nul-terminated string solely consists of ASCII
|
||||
* characters.
|
||||
*
|
||||
* @param s nul-terminated string to check
|
||||
*/
|
||||
bool lnm_is_ascii(const char *s);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -45,6 +45,10 @@ lnm_err lnm_http_router_init(lnm_http_router **out);
|
|||
|
||||
void lnm_http_router_free(lnm_http_router *router);
|
||||
|
||||
/**
|
||||
* Insert a new path & method in the given router, returning a handle to the
|
||||
* newly created route struct.
|
||||
*/
|
||||
lnm_err lnm_http_router_add(lnm_http_route **out, lnm_http_router *http_router,
|
||||
lnm_http_method method, const char *path);
|
||||
|
||||
|
|
@ -67,14 +71,26 @@ lnm_err lnm_http_router_merge(lnm_http_router *r1, lnm_http_router *r2);
|
|||
lnm_err lnm_http_router_nest(lnm_http_router *parent, lnm_http_router *child,
|
||||
const char *prefix);
|
||||
|
||||
/**
|
||||
* Route the given path & method.
|
||||
*/
|
||||
lnm_http_route_err lnm_http_router_route(lnm_http_route_match *out,
|
||||
const lnm_http_router *router,
|
||||
lnm_http_method method,
|
||||
const char *path);
|
||||
|
||||
/**
|
||||
* Retrieve a path segment using its name.
|
||||
*
|
||||
* @return NULL if not found, otherwise pointer to the match segment struct
|
||||
* representing the key
|
||||
*/
|
||||
const lnm_http_route_match_segment *
|
||||
lnm_http_route_match_get(lnm_http_route_match *match, const char *key);
|
||||
|
||||
/**
|
||||
* Append the given step function to the route's step list.
|
||||
*/
|
||||
lnm_err lnm_http_route_step_append(lnm_http_route *route, lnm_http_step_fn fn,
|
||||
bool blocking);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue