Struct reroute::RouterBuilder
[−]
[src]
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]
fn new() -> RouterBuilder
Create a new RouterBuilder
with no route handlers.
fn route<H>(
&mut self,
verb: Method,
route: &str,
handler: H
) -> &mut RouterBuilder where
H: Fn(Request, Response, Captures) + Send + Sync + 'static,
&mut self,
verb: Method,
route: &str,
handler: H
) -> &mut RouterBuilder where
H: Fn(Request, Response, Captures) + Send + Sync + 'static,
Install a handler for requests of method verb
and which have paths
matching route
. There are also convenience methods named after the
appropriate verb.
fn finalize(self) -> Result<Router, Error>
Compile the routes in a RouterBuilder
to produce a Router
capable
of handling Hyper requests.
fn get<H>(&mut self, route: &str, handler: H) -> &mut RouterBuilder where
H: Fn(Request, Response, Captures) + Send + Sync + 'static,
H: Fn(Request, Response, Captures) + Send + Sync + 'static,
Convenience method to install a GET handler.
fn post<H>(&mut self, route: &str, handler: H) -> &mut RouterBuilder where
H: Fn(Request, Response, Captures) + Send + Sync + 'static,
H: Fn(Request, Response, Captures) + Send + Sync + 'static,
Convenience method to install a POST handler.
fn put<H>(&mut self, route: &str, handler: H) -> &mut RouterBuilder where
H: Fn(Request, Response, Captures) + Send + Sync + 'static,
H: Fn(Request, Response, Captures) + Send + Sync + 'static,
Convenience method to install a PUT handler.
fn patch<H>(&mut self, route: &str, handler: H) -> &mut RouterBuilder where
H: Fn(Request, Response, Captures) + Send + Sync + 'static,
H: Fn(Request, Response, Captures) + Send + Sync + 'static,
Convenience method to install a PATCH handler.
fn delete<H>(&mut self, route: &str, handler: H) -> &mut RouterBuilder where
H: Fn(Request, Response, Captures) + Send + Sync + 'static,
H: Fn(Request, Response, Captures) + Send + Sync + 'static,
Convenience method to install a DELETE handler.
fn options<H>(&mut self, route: &str, handler: H) -> &mut RouterBuilder where
H: Fn(Request, Response, Captures) + Send + Sync + 'static,
H: Fn(Request, Response, Captures) + Send + Sync + 'static,
Convenience method to install an OPTIONS handler.
fn not_found<H>(&mut self, not_found: H) -> &mut RouterBuilder where
H: Fn(Request, Response, Captures) + Send + Sync + 'static,
H: Fn(Request, Response, Captures) + Send + Sync + 'static,
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.