diff --git a/axum-core/src/response/into_response.rs b/axum-core/src/response/into_response.rs index ab684e2c..91355b69 100644 --- a/axum-core/src/response/into_response.rs +++ b/axum-core/src/response/into_response.rs @@ -190,6 +190,12 @@ impl IntoResponse for String { } } +impl IntoResponse for Box { + fn into_response(self) -> Response { + String::from(self).into_response() + } +} + impl IntoResponse for Cow<'static, str> { fn into_response(self) -> Response { let mut res = Body::from(self).into_response(); @@ -315,6 +321,12 @@ impl IntoResponse for Vec { } } +impl IntoResponse for Box<[u8]> { + fn into_response(self) -> Response { + Vec::from(self).into_response() + } +} + impl IntoResponse for Cow<'static, [u8]> { fn into_response(self) -> Response { let mut res = Body::from(self).into_response(); diff --git a/axum/CHANGELOG.md b/axum/CHANGELOG.md index 9697969a..9d5388d1 100644 --- a/axum/CHANGELOG.md +++ b/axum/CHANGELOG.md @@ -53,6 +53,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **breaking:** Only inherit fallbacks for routers nested with `Router::nest`. Routers nested with `Router::nest_service` will no longer inherit fallbacks ([#1956]) - **fixed:** Don't remove the `Sec-WebSocket-Key` header in `WebSocketUpgrade` ([#1972]) +- **added:** Implement `IntoResponse` for `Box` and `Box<[u8]>` ([#2035]) [#1664]: https://github.com/tokio-rs/axum/pull/1664 [#1751]: https://github.com/tokio-rs/axum/pull/1751