[−][src]Struct reroute::RouterBuilder
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]
&mut self,
verb: Method,
route: &str,
handler: H
) -> &mut RouterBuilder where
H: Fn(Request<Body>, Captures) -> Response<Body> + 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.
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]
H: Fn(Request<Body>, Captures) -> Response<Body> + Send + Sync + 'static,
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]
H: Fn(Request<Body>, Captures) -> Response<Body> + Send + Sync + 'static,
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]
H: Fn(Request<Body>, Captures) -> Response<Body> + Send + Sync + 'static,
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]
H: Fn(Request<Body>, Captures) -> Response<Body> + Send + Sync + 'static,
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]
H: Fn(Request<Body>, Captures) -> Response<Body> + Send + Sync + 'static,
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]
H: Fn(Request<Body>, Captures) -> Response<Body> + Send + Sync + 'static,
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]
H: Fn(Request<Body>, Captures) -> Response<Body> + 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.
Trait Implementations
impl Default for RouterBuilder
[src]
fn default() -> RouterBuilder
[src]
Auto Trait Implementations
impl !RefUnwindSafe for RouterBuilder
impl Send for RouterBuilder
impl Sync for RouterBuilder
impl Unpin for RouterBuilder
impl !UnwindSafe for RouterBuilder
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,