const-router
const-router is a small string-key router that can be built in a static.
Routes are declared with a macro, sorted at compile time, and dispatched with a
binary search. The router also implements tower::Service.
Features
router!builds aRouterfrom static route keys and handlers.#[handler]converts sync or async functions returningResultinto router handlers.ExtractKeylets request types choose the string used for routing.- The optional
httpfeature implementsExtractKeyforhttp::Request<T>using the URI path.
Example
use ;
static ROUTER: = router! ;
# async
Handler Functions
Handlers can be synchronous or asynchronous functions. They must return
Result<TResponse, TError> and may take either zero arguments or one request
argument.
# use handler;
# ;
async
HTTP Requests
Enable the http feature to route http::Request<T> values by URI path.
[]
= { = "0.1", = ["http"] }
License
Licensed under either of:
- Apache License, Version 2.0
- MIT license
at your option.