Struct nickel::router::router::Router [] [src]

pub struct Router<D = ()> {
    // some fields omitted
}

The Router's job is it to hold routes and to resolve them later against concrete URLs. The router is also a regular middleware and needs to be added to the middleware stack with server.utilize(router).

Methods

impl<D> Router<D>
[src]

fn new() -> Router<D>

fn match_route<'mw>(&'mw self, method: &Method, path: &str) -> Option<RouteResult<'mw, D>>

Trait Implementations

impl<D> HttpRouter<D> for Router<D>
[src]

fn add_route<M: Into<Matcher>, H: Middleware<D>>(&mut self, method: Method, matcher: M, handler: H) -> &mut Self

Registers a handler to be used for a specified method. A handler can be anything implementing the RequestHandler trait. Read more

fn get<M: Into<Matcher>, H: Middleware<D>>(&mut self, matcher: M, handler: H) -> &mut Self

Registers a handler to be used for a specific GET request. Handlers are assigned to paths and paths are allowed to contain variables and wildcards. Read more

fn post<M: Into<Matcher>, H: Middleware<D>>(&mut self, matcher: M, handler: H) -> &mut Self

Registers a handler to be used for a specific POST request. Read more

fn put<M: Into<Matcher>, H: Middleware<D>>(&mut self, matcher: M, handler: H) -> &mut Self

Registers a handler to be used for a specific PUT request. Read more

fn delete<M: Into<Matcher>, H: Middleware<D>>(&mut self, matcher: M, handler: H) -> &mut Self

Registers a handler to be used for a specific DELETE request. Read more

fn options<M: Into<Matcher>, H: Middleware<D>>(&mut self, matcher: M, handler: H) -> &mut Self

Registers a handler to be used for a specific OPTIONS request. Read more

fn patch<M: Into<Matcher>, H: Middleware<D>>(&mut self, matcher: M, handler: H) -> &mut Self

Registers a handler to be used for a specific PATCH request. Read more

impl<D: 'static> Middleware<D> for Router<D>
[src]

fn invoke<'mw, 'conn>(&'mw self, req: &mut Request<'mw, 'conn, D>, res: Response<'mw, D>) -> MiddlewareResult<'mw, D>