pub struct Router<S, R = Response> { /* private fields */ }Expand description
Fixed-path router with middleware chain.
Implementations§
Source§impl<S, R> Router<S, R>
impl<S, R> Router<S, R>
Sourcepub fn delete<F, Fut>(self, path: impl Into<String>, handler: F) -> Self
pub fn delete<F, Fut>(self, path: impl Into<String>, handler: F) -> Self
Registers a DELETE route.
Sourcepub fn patch<F, Fut>(self, path: impl Into<String>, handler: F) -> Self
pub fn patch<F, Fut>(self, path: impl Into<String>, handler: F) -> Self
Registers a PATCH route.
Sourcepub fn options<F, Fut>(self, path: impl Into<String>, handler: F) -> Self
pub fn options<F, Fut>(self, path: impl Into<String>, handler: F) -> Self
Registers an OPTIONS route.
Sourcepub fn any<F, Fut>(self, path: impl Into<String>, handler: F) -> Self
pub fn any<F, Fut>(self, path: impl Into<String>, handler: F) -> Self
Registers a route for any method.
Sourcepub fn on<F, Fut>(
self,
method: Method,
path: impl Into<String>,
handler: F,
) -> Self
pub fn on<F, Fut>( self, method: Method, path: impl Into<String>, handler: F, ) -> Self
Registers a route for an explicit method token.
Sourcepub fn middleware<F, Fut>(self, middleware: F) -> Self
pub fn middleware<F, Fut>(self, middleware: F) -> Self
Adds a middleware to the end of the chain.
The middleware applies to all routes currently registered on this router and to
any routes added later on the same router value. Middleware attached to another
router does not leak across Self::merge.
Sourcepub fn merge(self, other: Self) -> Self
pub fn merge(self, other: Self) -> Self
Merges routes and middleware from another router with the same state.
Sourcepub async fn handle_routed(&self, request: RoutedRequest) -> R
pub async fn handle_routed(&self, request: RoutedRequest) -> R
Dispatches a routed request entirely in-process.
Trait Implementations§
Auto Trait Implementations§
impl<S, R> Freeze for Router<S, R>where
S: Freeze,
impl<S, R = Response> !RefUnwindSafe for Router<S, R>
impl<S, R> Send for Router<S, R>where
S: Send,
impl<S, R> Sync for Router<S, R>where
S: Sync,
impl<S, R> Unpin for Router<S, R>where
S: Unpin,
impl<S, R> UnsafeUnpin for Router<S, R>where
S: UnsafeUnpin,
impl<S, R = Response> !UnwindSafe for Router<S, R>
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