|
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 |
| - }, |
| 6 | + extract::connect_info::{Connected, IntoMakeServiceWithConnectInfo}, |
10 | 7 | response::Response,
|
11 | 8 | routing::strip_prefix::StripPrefix,
|
12 | 9 | util::{try_downcast, ByteStr, PercentDecodedByteStr},
|
@@ -400,7 +397,10 @@ where
|
400 | 397 | let id = *match_.value;
|
401 | 398 | req.extensions_mut().insert(id);
|
402 | 399 |
|
| 400 | + #[cfg(feature = "matched-path")] |
403 | 401 | if let Some(matched_path) = self.node.route_id_to_path.get(&id) {
|
| 402 | + use crate::extract::MatchedPath; |
| 403 | + |
404 | 404 | let matched_path = if let Some(previous) = req.extensions_mut().get::<MatchedPath>() {
|
405 | 405 | // a previous `MatchedPath` might exist if we're inside a nested Router
|
406 | 406 | let previous = if let Some(previous) =
|
@@ -471,9 +471,14 @@ where
|
471 | 471 |
|
472 | 472 | #[inline]
|
473 | 473 | fn call(&mut self, mut req: Request<B>) -> Self::Future {
|
474 |
| - if req.extensions().get::<OriginalUri>().is_none() { |
475 |
| - let original_uri = OriginalUri(req.uri().clone()); |
476 |
| - req.extensions_mut().insert(original_uri); |
| 474 | + #[cfg(feature = "original-uri")] |
| 475 | + { |
| 476 | + use crate::extract::OriginalUri; |
| 477 | + |
| 478 | + if req.extensions().get::<OriginalUri>().is_none() { |
| 479 | + let original_uri = OriginalUri(req.uri().clone()); |
| 480 | + req.extensions_mut().insert(original_uri); |
| 481 | + } |
477 | 482 | }
|
478 | 483 |
|
479 | 484 | let path = req.uri().path().to_owned();
|
|
0 commit comments