mirror of
https://github.com/tokio-rs/axum.git
synced 2026-09-07 00:00:12 +02:00
Implement IntoResponse for Response<()> and response::Parts (#950)
* feat(axum-core): add IntoResponse for `http::response` types * chore: narrow impl to `Response<()>` * include extensions * changelog Co-authored-by: David Pedersen <[email protected]>
This commit is contained in:
co-authored by
David Pedersen
parent
5bb924b3a2
commit
6e1835074c
@@ -404,6 +404,27 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<R> IntoResponse for (http::response::Parts, R)
|
||||
where
|
||||
R: IntoResponse,
|
||||
{
|
||||
fn into_response(self) -> Response {
|
||||
let (parts, res) = self;
|
||||
(parts.status, parts.headers, parts.extensions, res).into_response()
|
||||
}
|
||||
}
|
||||
|
||||
impl<R> IntoResponse for (http::response::Response<()>, R)
|
||||
where
|
||||
R: IntoResponse,
|
||||
{
|
||||
fn into_response(self) -> Response {
|
||||
let (template, res) = self;
|
||||
let (parts, ()) = template.into_parts();
|
||||
(parts, res).into_response()
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! impl_into_response {
|
||||
( $($ty:ident),* $(,)? ) => {
|
||||
#[allow(non_snake_case)]
|
||||
|
||||
Reference in New Issue
Block a user