Reuse X_REQUEST_ID constant for inbound header lookup

Both Cursor Bugbot and Cubic flagged that the inbound `headers().get(...)`
call constructed `HeaderName::from_static("x-request-id")` inline instead
of reusing the `X_REQUEST_ID` constant defined at the top of the file.
The two were already kept in sync by both being `from_static("x-request-id")`,
but a future rename would have to touch both sites or risk silent drift
between read and write.

Also drops the now-unused `header` module import.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Ragnor Comerford 2026-04-26 12:05:19 +02:00
parent 284c9377c2
commit e14b203208
No known key found for this signature in database

View file

@ -9,7 +9,7 @@
use axum::{
body::Body,
extract::Request,
http::{HeaderName, HeaderValue, header},
http::{HeaderName, HeaderValue},
middleware::Next,
response::Response,
};
@ -40,7 +40,7 @@ fn is_valid_inbound(raw: &str) -> bool {
pub async fn request_id_middleware(mut req: Request<Body>, next: Next) -> Response {
let inbound = req
.headers()
.get(header::HeaderName::from_static("x-request-id"))
.get(&X_REQUEST_ID)
.and_then(|v| v.to_str().ok())
.filter(|raw| is_valid_inbound(raw));