diff --git a/axum-core/CHANGELOG.md b/axum-core/CHANGELOG.md index 276f70a0..268c504d 100644 --- a/axum-core/CHANGELOG.md +++ b/axum-core/CHANGELOG.md @@ -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) diff --git a/axum-core/src/response/into_response.rs b/axum-core/src/response/into_response.rs index e14936bb..23beaa5f 100644 --- a/axum-core/src/response/into_response.rs +++ b/axum-core/src/response/into_response.rs @@ -404,6 +404,27 @@ where } } +impl 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 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)]