[][src]Struct reroute::RouterBuilder

pub struct RouterBuilder { /* fields omitted */ }

A RouterBuilder enables you to build up a set of routes and their handlers to be handled by a Router.

Methods

impl RouterBuilder[src]

pub fn new() -> RouterBuilder[src]

Create a new RouterBuilder with no route handlers.

pub fn route<H>(
    &mut self,
    verb: Method,
    route: &str,
    handler: H
) -> &mut RouterBuilder where
    H: Fn(Request<Body>, Captures) -> Response<Body> + Send + Sync + 'static, 
[src]

Install a handler for requests of method verb and which have paths matching route. There are also convenience methods named after the appropriate verb.

pub fn finalize(self) -> Result<Router, Error>[src]

Compile the routes in a RouterBuilder to produce a Router capable of handling Hyper requests.

pub fn get<H>(&mut self, route: &str, handler: H) -> &mut RouterBuilder where
    H: Fn(Request<Body>, Captures) -> Response<Body> + Send + Sync + 'static, 
[src]

Convenience method to install a GET handler.

pub fn post<H>(&mut self, route: &str, handler: H) -> &mut RouterBuilder where
    H: Fn(Request<Body>, Captures) -> Response<Body> + Send + Sync + 'static, 
[src]

Convenience method to install a POST handler.

pub fn put<H>(&mut self, route: &str, handler: H) -> &mut RouterBuilder where
    H: Fn(Request<Body>, Captures) -> Response<Body> + Send + Sync + 'static, 
[src]

Convenience method to install a PUT handler.

pub fn patch<H>(&mut self, route: &str, handler: H) -> &mut RouterBuilder where
    H: Fn(Request<Body>, Captures) -> Response<Body> + Send + Sync + 'static, 
[src]

Convenience method to install a PATCH handler.

pub fn delete<H>(&mut self, route: &str, handler: H) -> &mut RouterBuilder where
    H: Fn(Request<Body>, Captures) -> Response<Body> + Send + Sync + 'static, 
[src]

Convenience method to install a DELETE handler.

pub fn options<H>(&mut self, route: &str, handler: H) -> &mut RouterBuilder where
    H: Fn(Request<Body>, Captures) -> Response<Body> + Send + Sync + 'static, 
[src]

Convenience method to install an OPTIONS handler.

pub fn not_found<H>(&mut self, not_found: H) -> &mut RouterBuilder where
    H: Fn(Request<Body>, Captures) -> Response<Body> + Send + Sync + 'static, 
[src]

Install a fallback handler for when there is no matching route for a request. If none is installed, the resulting Router will use a default handler.

Trait Implementations

impl Default for RouterBuilder[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.