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§
Trait Implementations§
Source§impl Clone for NestedPath
impl Clone for NestedPath
Source§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 moreSource§impl Debug for NestedPath
impl Debug for NestedPath
Source§impl<S> FromRequestParts<S> for NestedPath
impl<S> FromRequestParts<S> for NestedPath
Source§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.
Source§async fn from_request_parts(
parts: &mut Parts,
_state: &S,
) -> Result<NestedPath, <NestedPath as FromRequestParts<S>>::Rejection>
async fn from_request_parts( parts: &mut Parts, _state: &S, ) -> Result<NestedPath, <NestedPath as FromRequestParts<S>>::Rejection>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S, T> FromRequest<S, ViaParts> for T
impl<S, T> FromRequest<S, ViaParts> for T
Source§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.
Source§async fn from_request(
req: Request<Body>,
state: &S,
) -> Result<T, <T as FromRequest<S, ViaParts>>::Rejection>
async fn from_request( req: Request<Body>, state: &S, ) -> Result<T, <T as FromRequest<S, ViaParts>>::Rejection>
Perform the extraction.