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

Be careful when using this code, it's not being tested!
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:

Be careful when using this code, it's not being tested!
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 error-chain

ext

Provides some extensions to Request, Response, and Router

Structs

Request

Hyper Request and the matching regex

Response

An HTTP Response

Router

The "finished" Router. See RouterBuilder for how to build a Router.

RouterBuilder

Builder for a Router

Traits

CaptureExtraction

Trait to provide parsed captures from path

FutureExt
Handler
IntoHandler

Handle the request

IntoResponse

Something that can be converted into a Response (cannot fail)

Type Definitions

BoxFuture