feat(routing): implement router merging
This commit is contained in:
parent
6eb965adcd
commit
2ce49a3347
3 changed files with 208 additions and 4 deletions
|
|
@ -49,11 +49,23 @@ lnm_err lnm_http_router_add(lnm_http_route **out, lnm_http_router *http_router,
|
|||
lnm_http_method method, const char *path);
|
||||
|
||||
/**
|
||||
* Add all of the child router's routes to the parent router, under the given
|
||||
* route prefix.
|
||||
* Checks whether the two routers have any conflicting parts.
|
||||
*/
|
||||
lnm_err lnm_http_router_nest(lnm_http_router *parent,
|
||||
const lnm_http_router *child, const char *prefix);
|
||||
bool lnm_http_router_conflicts(const lnm_http_router *r1,
|
||||
const lnm_http_router *r2);
|
||||
|
||||
/**
|
||||
* Merge two routers, with the result ending up in r1. This is equivalent to
|
||||
* nesting a router on '/'.
|
||||
*/
|
||||
lnm_err lnm_http_router_merge(lnm_http_router *r1, lnm_http_router *r2);
|
||||
|
||||
/**
|
||||
* Integrate the child router into the parent routing, mounting its paths on the
|
||||
* given prefix.
|
||||
*/
|
||||
lnm_err lnm_http_router_nest(lnm_http_router *parent, lnm_http_router *child,
|
||||
const char *prefix);
|
||||
|
||||
lnm_http_route_err lnm_http_router_route(lnm_http_route_match *out,
|
||||
const lnm_http_router *router,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue