Struct hyper_router::Router [] [src]

pub struct Router {
    // some fields omitted
}

This is the one. The router.

Example usage:

let router = RouterBuilder::new()
    .add(Route {
        method: Get,
        path: Path::new(r"/person/\d+"),
        handler: some_handler
    })
    .build();

 // later when processing request:
 let handler = router.find_handler(&request);
 handler(request, response);

Methods

impl Router

fn find_handler(&self, request: &Request) -> Handler

Finds handler for given Hyper request.

If the request does not match any route than default 404 handler is returned. If the request match some routes but http method does not match (used GET but routes are defined for POST) than default method not supported handler is returned. Finally in case of error - internal server error handler is returned.

fn find_matching_routes(&self, request_path: &str) -> Vec<&Route>

Returns vector of Routes that match to given path.

Trait Implementations

Derived Implementations

impl Debug for Router

fn fmt(&self, __arg_0: &mut Formatter) -> Result