Skip to content

Commit 31d2bf6

Browse files
committed
axum: Remove Option<Extension<MatchedPath>> extractor
This is currently not supported by axum, but we dont really need it here anyway.
1 parent 517b489 commit 31d2bf6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/middleware/cargo_compat.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use axum::extract::{MatchedPath, Request, State};
22
use axum::middleware::Next;
33
use axum::response::{IntoResponse, Response};
4-
use axum::{Extension, Json};
4+
use axum::Json;
55
use http::{header, Method, StatusCode};
66
use std::str::FromStr;
77

@@ -36,12 +36,13 @@ impl FromStr for StatusCodeConfig {
3636
/// Convert plain text errors into JSON errors and adjust status codes.
3737
pub async fn middleware(
3838
State(config): State<StatusCodeConfig>,
39-
matched_path: Option<Extension<MatchedPath>>,
4039
req: Request,
4140
next: Next,
4241
) -> Response {
4342
let is_api_request = req.uri().path().starts_with("/api/");
44-
let is_cargo_endpoint = matched_path
43+
let is_cargo_endpoint = req
44+
.extensions()
45+
.get::<MatchedPath>()
4546
.map(|m| is_cargo_endpoint(req.method(), m.as_str()))
4647
.unwrap_or(false);
4748

0 commit comments

Comments
 (0)