pub struct Router<D = ()> { /* private fields */ }
Expand description
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)
.
Implementations
Trait Implementations
sourceimpl<D> HttpRouter<D> for Router<D>
impl<D> HttpRouter<D> for Router<D>
sourcefn add_route<M: Into<Matcher>, H: Middleware<D>>(
&mut self,
method: Method,
matcher: M,
handler: H
) -> &mut Self
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 moresourcefn get<M: Into<Matcher>, H: Middleware<D>>(
&mut self,
matcher: M,
handler: H
) -> &mut Self
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
sourcefn post<M: Into<Matcher>, H: Middleware<D>>(
&mut self,
matcher: M,
handler: H
) -> &mut Self
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
sourcefn put<M: Into<Matcher>, H: Middleware<D>>(
&mut self,
matcher: M,
handler: H
) -> &mut Self
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
sourcefn delete<M: Into<Matcher>, H: Middleware<D>>(
&mut self,
matcher: M,
handler: H
) -> &mut Self
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
sourceimpl<D: 'static> Middleware<D> for Router<D>
impl<D: 'static> Middleware<D> for Router<D>
fn invoke<'mw, 'conn>(
&'mw self,
req: &mut Request<'mw, 'conn, D>,
res: Response<'mw, D>
) -> MiddlewareResult<'mw, D>
Auto Trait Implementations
impl<D = ()> !RefUnwindSafe for Router<D>
impl<D> Send for Router<D>
impl<D> Sync for Router<D>
impl<D> Unpin for Router<D>
impl<D = ()> !UnwindSafe for Router<D>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more