Skip to content

Commit

Permalink
axum-extra: Log rejections of TypedHeader (#2738)
Browse files Browse the repository at this point in the history
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
  • Loading branch information
mladedav and jplatte committed May 27, 2024
1 parent 4452519 commit 0a92e31
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions axum-extra/src/typed_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use axum::{
response::{IntoResponse, IntoResponseParts, Response, ResponseParts},
};
use headers::{Header, HeaderMapExt};
use http::request::Parts;
use http::{request::Parts, StatusCode};
use std::convert::Infallible;

/// Extractor and response that works with typed header values from [`headers`].
Expand Down Expand Up @@ -156,7 +156,10 @@ impl TypedHeaderRejectionReason {

impl IntoResponse for TypedHeaderRejection {
fn into_response(self) -> Response {
(http::StatusCode::BAD_REQUEST, self.to_string()).into_response()
let status = StatusCode::BAD_REQUEST;
let body = self.to_string();
axum_core::__log_rejection!(rejection_type = Self, body_text = body, status = status,);
(status, body).into_response()
}
}

Expand Down

0 comments on commit 0a92e31

Please sign in to comment.