mirror of
https://github.com/tokio-rs/axum.git
synced 2025-10-02 07:20:38 +00:00
axum-extra: Log rejections of TypedHeader
(#2738)
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
This commit is contained in:
parent
4452519689
commit
0a92e31a50
@ -6,7 +6,7 @@ use axum::{
|
|||||||
response::{IntoResponse, IntoResponseParts, Response, ResponseParts},
|
response::{IntoResponse, IntoResponseParts, Response, ResponseParts},
|
||||||
};
|
};
|
||||||
use headers::{Header, HeaderMapExt};
|
use headers::{Header, HeaderMapExt};
|
||||||
use http::request::Parts;
|
use http::{request::Parts, StatusCode};
|
||||||
use std::convert::Infallible;
|
use std::convert::Infallible;
|
||||||
|
|
||||||
/// Extractor and response that works with typed header values from [`headers`].
|
/// Extractor and response that works with typed header values from [`headers`].
|
||||||
@ -156,7 +156,10 @@ impl TypedHeaderRejectionReason {
|
|||||||
|
|
||||||
impl IntoResponse for TypedHeaderRejection {
|
impl IntoResponse for TypedHeaderRejection {
|
||||||
fn into_response(self) -> Response {
|
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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user