From 0151aeea54b2726eba6352095337aff54d621458 Mon Sep 17 00:00:00 2001 From: kinrany Date: Wed, 26 Jul 2023 20:05:42 +0400 Subject: [PATCH] docs: delete MatchedPath nesting section (#2121) --- axum/src/extract/matched_path.rs | 37 -------------------------------- 1 file changed, 37 deletions(-) diff --git a/axum/src/extract/matched_path.rs b/axum/src/extract/matched_path.rs index a3fb5800..cdb49b4d 100644 --- a/axum/src/extract/matched_path.rs +++ b/axum/src/extract/matched_path.rs @@ -52,43 +52,6 @@ use std::{collections::HashMap, sync::Arc}; /// ); /// # let _: Router = app; /// ``` -/// -/// # Matched path in nested routers -/// -/// Because of how [nesting] works `MatchedPath` isn't accessible in middleware on nested routes: -/// -/// ``` -/// use axum::{ -/// Router, -/// RequestExt, -/// routing::get, -/// extract::{Request, MatchedPath, rejection::MatchedPathRejection}, -/// middleware::map_request, -/// body::Body, -/// }; -/// -/// async fn access_matched_path(mut request: Request) -> Request { -/// // if `/foo/bar` is called this will be `Err(_)` since that matches -/// // a nested route -/// let matched_path: Result = -/// request.extract_parts::().await; -/// -/// request -/// } -/// -/// // `MatchedPath` is always accessible on handlers added via `Router::route` -/// async fn handler(matched_path: MatchedPath) {} -/// -/// let app = Router::new() -/// .nest( -/// "/foo", -/// Router::new().route("/bar", get(handler)), -/// ) -/// .layer(map_request(access_matched_path)); -/// # let _: Router = app; -/// ``` -/// -/// [nesting]: crate::Router::nest #[cfg_attr(docsrs, doc(cfg(feature = "matched-path")))] #[derive(Clone, Debug)] pub struct MatchedPath(pub(crate) Arc);