|
3 | 3 | use self::{future::RouterFuture, not_found::NotFound};
|
4 | 4 | use crate::{
|
5 | 5 | body::{boxed, Body, Bytes, HttpBody},
|
6 |
| - extract::{ |
7 |
| - connect_info::{Connected, IntoMakeServiceWithConnectInfo}, |
8 |
| - MatchedPath, OriginalUri, |
9 |
| - }, |
10 |
| - response::IntoResponse, |
11 |
| - response::Redirect, |
12 |
| - response::Response, |
| 6 | + extract::connect_info::{Connected, IntoMakeServiceWithConnectInfo}, |
| 7 | + response::{Response, Redirect, IntoResponse}, |
13 | 8 | routing::strip_prefix::StripPrefix,
|
14 | 9 | util::{try_downcast, ByteStr, PercentDecodedByteStr},
|
15 | 10 | BoxError,
|
@@ -405,7 +400,10 @@ where
|
405 | 400 | let id = *match_.value;
|
406 | 401 | req.extensions_mut().insert(id);
|
407 | 402 |
|
| 403 | + #[cfg(feature = "matched-path")] |
408 | 404 | if let Some(matched_path) = self.node.route_id_to_path.get(&id) {
|
| 405 | + use crate::extract::MatchedPath; |
| 406 | + |
409 | 407 | let matched_path = if let Some(previous) = req.extensions_mut().get::<MatchedPath>() {
|
410 | 408 | // a previous `MatchedPath` might exist if we're inside a nested Router
|
411 | 409 | let previous = if let Some(previous) =
|
@@ -476,9 +474,14 @@ where
|
476 | 474 |
|
477 | 475 | #[inline]
|
478 | 476 | fn call(&mut self, mut req: Request<B>) -> Self::Future {
|
479 |
| - if req.extensions().get::<OriginalUri>().is_none() { |
480 |
| - let original_uri = OriginalUri(req.uri().clone()); |
481 |
| - req.extensions_mut().insert(original_uri); |
| 477 | + #[cfg(feature = "original-uri")] |
| 478 | + { |
| 479 | + use crate::extract::OriginalUri; |
| 480 | + |
| 481 | + if req.extensions().get::<OriginalUri>().is_none() { |
| 482 | + let original_uri = OriginalUri(req.uri().clone()); |
| 483 | + req.extensions_mut().insert(original_uri); |
| 484 | + } |
482 | 485 | }
|
483 | 486 |
|
484 | 487 | let path = req.uri().path().to_owned();
|
|
0 commit comments