pub struct NestedPath(/* private fields */);
Expand description
Access the path the matched the route is nested at.
This can for example be used when doing redirects.
§Example
use axum::{
Router,
extract::NestedPath,
routing::get,
};
let api = Router::new().route(
"/users",
get(|path: NestedPath| async move {
// `path` will be "/api" because thats what this
// router is nested at when we build `app`
let path = path.as_str();
})
);
let app = Router::new().nest("/api", api);
Implementations§
§impl NestedPath
impl NestedPath
Trait Implementations§
§impl Clone for NestedPath
impl Clone for NestedPath
§fn clone(&self) -> NestedPath
fn clone(&self) -> NestedPath
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more§impl Debug for NestedPath
impl Debug for NestedPath
§impl<S> FromRequestParts<S> for NestedPath
impl<S> FromRequestParts<S> for NestedPath
§type Rejection = NestedPathRejection
type Rejection = NestedPathRejection
If the extractor fails it’ll use this “rejection” type. A rejection is
a kind of error that can be converted into a response.
§fn from_request_parts<'life0, 'life1, 'async_trait>(
parts: &'life0 mut Parts,
_state: &'life1 S
) -> Pin<Box<dyn Future<Output = Result<NestedPath, <NestedPath as FromRequestParts<S>>::Rejection>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
NestedPath: 'async_trait,
fn from_request_parts<'life0, 'life1, 'async_trait>(
parts: &'life0 mut Parts,
_state: &'life1 S
) -> Pin<Box<dyn Future<Output = Result<NestedPath, <NestedPath as FromRequestParts<S>>::Rejection>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
NestedPath: 'async_trait,
Perform the extraction.
Auto Trait Implementations§
impl Freeze for NestedPath
impl RefUnwindSafe for NestedPath
impl Send for NestedPath
impl Sync for NestedPath
impl Unpin for NestedPath
impl UnwindSafe for NestedPath
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
§impl<S, T> FromRequest<S, ViaParts> for T
impl<S, T> FromRequest<S, ViaParts> for T
§type Rejection = <T as FromRequestParts<S>>::Rejection
type Rejection = <T as FromRequestParts<S>>::Rejection
If the extractor fails it’ll use this “rejection” type. A rejection is
a kind of error that can be converted into a response.