mirror of
https://github.com/tokio-rs/axum.git
synced 2026-09-07 00:00:12 +02:00
Fix IntoResponse for tuples overriding error response codes (#3603)
Co-authored-by: David Pedersen <[email protected]> Co-authored-by: Yann Simon <[email protected]>
This commit is contained in:
co-authored by
David Pedersen
Yann Simon
parent
81e727faf6
commit
576968b406
@@ -4,7 +4,7 @@ use axum_core::__composite_rejection as composite_rejection;
|
||||
use axum_core::__define_rejection as define_rejection;
|
||||
use axum_core::{
|
||||
extract::{rejection::BytesRejection, FromRequest, Request},
|
||||
response::{IntoResponse, Response},
|
||||
response::{IntoResponse, IntoResponseFailed, Response},
|
||||
RequestExt,
|
||||
};
|
||||
use bytes::BytesMut;
|
||||
@@ -131,7 +131,12 @@ where
|
||||
let mut buf = BytesMut::with_capacity(self.0.encoded_len());
|
||||
match &self.0.encode(&mut buf) {
|
||||
Ok(()) => buf.into_response(),
|
||||
Err(err) => (StatusCode::INTERNAL_SERVER_ERROR, err.to_string()).into_response(),
|
||||
Err(err) => (
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
IntoResponseFailed,
|
||||
err.to_string(),
|
||||
)
|
||||
.into_response(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use axum_core::response::{IntoResponse, Response};
|
||||
use axum_core::response::{IntoResponse, IntoResponseFailed, Response};
|
||||
use bytes::{BufMut, Bytes, BytesMut};
|
||||
use http::{header, HeaderValue, StatusCode};
|
||||
use serde_core::Serialize;
|
||||
@@ -78,7 +78,12 @@ impl IntoResponse for ErasedJson {
|
||||
bytes,
|
||||
)
|
||||
.into_response(),
|
||||
Err(err) => (StatusCode::INTERNAL_SERVER_ERROR, err.to_string()).into_response(),
|
||||
Err(err) => (
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
IntoResponseFailed,
|
||||
err.to_string(),
|
||||
)
|
||||
.into_response(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user