From 46b1ec271210bd2c77b24dd682139f35e1ca38b1 Mon Sep 17 00:00:00 2001 From: Ruslan Fadeev Date: Wed, 26 Jul 2023 19:40:34 +0400 Subject: [PATCH] docs: delete MatchedPath nesting section --- 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 a3fb580034..cdb49b4db3 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);