mirror of
https://github.com/tokio-rs/axum.git
synced 2025-04-26 13:56:22 +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 <david.pdrsn@gmail.com>
This commit is contained in:
parent
5bb924b3a2
commit
6e1835074c
2 changed files with 24 additions and 0 deletions
axum-core
|
@ -8,7 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
# Unreleased
|
||||
|
||||
- **added:** Implement `IntoResponse` and `IntoResponseParts` for `http::Extensions` ([#975])
|
||||
- **added:** Implement `IntoResponse` for `(http::response::Parts, impl IntoResponse)` ([#950])
|
||||
- **added:** Implement `IntoResponse` for `(http::response::Response<()>, impl IntoResponse)` ([#950])
|
||||
|
||||
[#950]: https://github.com/tokio-rs/axum/pull/950
|
||||
[#975]: https://github.com/tokio-rs/axum/pull/975
|
||||
|
||||
# 0.2.3 (25. April, 2022)
|
||||
|
|
|
@ -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)]
|
||||
|
|
Loading…
Add table
Reference in a new issue