pub struct MountedApp { /* private fields */ }Expand description
A mounted sub-application with its path prefix.
Mounted applications are completely independent from the parent app:
- They have their own middleware stack
- They have their own state and configuration
- Their OpenAPI schemas are NOT merged with the parent
- Request paths have the prefix stripped before being passed to the sub-app
This differs from include_router, which merges routes into the parent app.
Implementations§
Source§impl MountedApp
impl MountedApp
Sourcepub fn new(prefix: impl Into<String>, app: App) -> Self
pub fn new(prefix: impl Into<String>, app: App) -> Self
Create a new mounted app at the given prefix.
The prefix should start with ‘/’ and not end with ‘/’.
Sourcepub fn match_prefix<'a>(&self, path: &'a str) -> Option<&'a str>
pub fn match_prefix<'a>(&self, path: &'a str) -> Option<&'a str>
Check if a request path matches this mount prefix.
Returns the remaining path after the prefix is stripped, or None if no match.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MountedApp
impl !RefUnwindSafe for MountedApp
impl Send for MountedApp
impl Sync for MountedApp
impl Unpin for MountedApp
impl !UnwindSafe for MountedApp
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).