Struct NestedPath

struct NestedPath(_)

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 that's what this
        // router is nested at when we build `app`
        let path = path.as_str();
    })
);

let app = Router::new().nest("/api", api);
# let _: Router = app;

Implementations

impl NestedPath

fn as_str(self: &Self) -> &str

Returns a str representation of the path.

impl Clone for NestedPath

fn clone(self: &Self) -> NestedPath

impl Debug for NestedPath

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl Freeze for NestedPath

impl RefUnwindSafe for NestedPath

impl Send for NestedPath

impl Sync for NestedPath

impl Unpin for NestedPath

impl UnsafeUnpin for NestedPath

impl UnwindSafe for NestedPath

impl<S> FromRequestParts for NestedPath

async fn from_request_parts(parts: &mut Parts, _state: &S) -> Result<Self, <Self as >::Rejection>

impl<S, T> FromRequest for NestedPath

fn from_request(req: Request<Body>, state: &S) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>

impl<T> Any for NestedPath

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for NestedPath

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for NestedPath

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for NestedPath

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for NestedPath

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> FromRef for NestedPath

fn from_ref(input: &T) -> T

impl<T> Instrument for NestedPath

impl<T> Same for NestedPath

impl<T> ToOwned for NestedPath

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T> WithSubscriber for NestedPath

impl<T, U> Into for NestedPath

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for NestedPath

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for NestedPath

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>

impl<V, T> VZip for NestedPath

fn vzip(self: Self) -> V