Crate reset_router [−] [src]
A RegexSet
based router for use with Hyper v0.11.x.
Similar to and inspired by reroute, but for async Hyper and potentially faster (no unnecessary string allocations, no hashmaps, and method-first-matching).
Enables request handling for functions that look like Fn(Request) -> RESPONSE
where Request
is a thin wrapper around hyper::server::Request
and
RESPONSE: IntoFuture<Future = F, Item = S, Error = E>, F: Future<Item = S, Error = E> + 'static + Send, S: IntoResponse, E: IntoResponse
This means you can return something as simple as Ok(Response::new())
. You don't have to worry about futures
unless you need to read the request body or interact with other future-aware things.
Use like:
let router = Router::build() .add_get(r"\A/\z", |_| Ok::<_, Response>(Response::new().with_body("ROOT path"))) .add_not_found(|_| Ok::<_, Response>(Response::new().with_body("Route not found"))) .finish() .unwrap(); router.quick_serve(8, "0.0.0.0:3000".parse().unwrap(), || Core::new().unwrap() );
See simple.rs for examples.
Modules
err |
Error handling with |
ext |
Provides some extensions to Request, Response, and Router |
Structs
Request |
Hyper |
Response |
An HTTP Response |
Router |
The "finished" |
RouterBuilder |
Builder for a |
Traits
CaptureExtraction |
Trait to provide parsed captures from path |
FutureExt | |
Handler | |
IntoHandler |
Handle the request |
IntoResponse |
Something that can be converted into a |
Type Definitions
BoxFuture |