pub struct Router<C> { /* private fields */ }Expand description
Routes request contexts by label and HTTP method.
Implementations§
Source§impl<C: HasRequest + Send + 'static> Router<C>
impl<C: HasRequest + Send + 'static> Router<C>
Sourcepub fn route<H: RequestHandler<C>>(
self,
label: impl Into<String>,
handler: H,
) -> Self
pub fn route<H: RequestHandler<C>>( self, label: impl Into<String>, handler: H, ) -> Self
Adds a route that matches label with any HTTP method.
Sourcepub fn route_method<H: RequestHandler<C>>(
self,
label: impl Into<String>,
method: Method,
handler: H,
) -> Self
pub fn route_method<H: RequestHandler<C>>( self, label: impl Into<String>, method: Method, handler: H, ) -> Self
Adds a route that matches label with one HTTP method.
Sourcepub fn route_methods<H, I>(
self,
label: impl Into<String>,
methods: I,
handler: H,
) -> Self
pub fn route_methods<H, I>( self, label: impl Into<String>, methods: I, handler: H, ) -> Self
Adds a route that matches label with any of the supplied HTTP methods.
Sourcepub fn default<H: RequestHandler<C>>(self, handler: H) -> Self
pub fn default<H: RequestHandler<C>>(self, handler: H) -> Self
Sets the fallback handler used when no registered route matches.
Sourcepub fn middleware<M: Middleware<C>>(self, middleware: M) -> Self
pub fn middleware<M: Middleware<C>>(self, middleware: M) -> Self
Appends middleware that runs in registration order before a matched handler.
Trait Implementations§
Source§impl<C: HasRequest + Send + 'static> RequestHandler<C> for Router<C>
impl<C: HasRequest + Send + 'static> RequestHandler<C> for Router<C>
Auto Trait Implementations§
impl<C> !RefUnwindSafe for Router<C>
impl<C> !UnwindSafe for Router<C>
impl<C> Freeze for Router<C>
impl<C> Send for Router<C>
impl<C> Sync for Router<C>
impl<C> Unpin for Router<C>
impl<C> UnsafeUnpin for Router<C>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more