mirror of
https://github.com/tokio-rs/axum.git
synced 2024-11-21 14:46:32 +01:00
Avoid cloning the uri/path
This commit is contained in:
parent
c417a28142
commit
236781cfdc
1 changed files with 6 additions and 5 deletions
|
@ -331,9 +331,9 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
let path = req.uri().path().to_owned();
|
||||
let (mut parts, body) = req.into_parts();
|
||||
|
||||
match self.node.at(&path) {
|
||||
match self.node.at(parts.uri.path()) {
|
||||
Ok(match_) => {
|
||||
let id = *match_.value;
|
||||
|
||||
|
@ -342,17 +342,18 @@ where
|
|||
crate::extract::matched_path::set_matched_path_for_request(
|
||||
id,
|
||||
&self.node.route_id_to_path,
|
||||
req.extensions_mut(),
|
||||
&mut parts.extensions,
|
||||
);
|
||||
}
|
||||
|
||||
url_params::insert_url_params(req.extensions_mut(), match_.params);
|
||||
url_params::insert_url_params(&mut parts.extensions, match_.params);
|
||||
|
||||
let endpoint = self
|
||||
.routes
|
||||
.get(&id)
|
||||
.expect("no route for id. This is a bug in axum. Please file an issue");
|
||||
|
||||
let req = Request::from_parts(parts, body);
|
||||
match endpoint {
|
||||
Endpoint::MethodRouter(method_router) => {
|
||||
Ok(method_router.call_with_state(req, state))
|
||||
|
@ -366,7 +367,7 @@ where
|
|||
MatchError::NotFound
|
||||
| MatchError::ExtraTrailingSlash
|
||||
| MatchError::MissingTrailingSlash,
|
||||
) => Err((req, state)),
|
||||
) => Err((Request::from_parts(parts, body), state)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue