From 62be8aaa18c889b7420937bdd4015715dc186e43 Mon Sep 17 00:00:00 2001 From: David Pedersen Date: Tue, 9 Nov 2021 20:50:29 +0100 Subject: [PATCH] Implement `IntoResponse` for `http::response::Parts` (#490) * Implement `IntoResponse` for `http::response::Parts` Not sure there are many use cases for this but still thinks it makes to provide since other crates can't. * Use `Response::from_parts` --- axum/CHANGELOG.md | 4 +++- axum/src/response/mod.rs | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/axum/CHANGELOG.md b/axum/CHANGELOG.md index 2d082f4a..cc9fdd2b 100644 --- a/axum/CHANGELOG.md +++ b/axum/CHANGELOG.md @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 # Unreleased -- None +- Implement `IntoResponse` for `http::response::Parts` ([#490]) + +[#490]: https://github.com/tokio-rs/axum/pull/490 # 0.3.2 (08. November, 2021) diff --git a/axum/src/response/mod.rs b/axum/src/response/mod.rs index 3f36eed7..59c24fcd 100644 --- a/axum/src/response/mod.rs +++ b/axum/src/response/mod.rs @@ -245,6 +245,15 @@ impl_into_response_for_body!(hyper::Body); impl_into_response_for_body!(Full); impl_into_response_for_body!(Empty); +impl IntoResponse for http::response::Parts { + type Body = Empty; + type BodyError = Infallible; + + fn into_response(self) -> Response { + Response::from_parts(self, Empty::new()) + } +} + impl IntoResponse for http_body::combinators::BoxBody where E: Into + 'static,