diff --git a/axum-core/src/response/into_response.rs b/axum-core/src/response/into_response.rs index 8f49d317..560fc585 100644 --- a/axum-core/src/response/into_response.rs +++ b/axum-core/src/response/into_response.rs @@ -3,7 +3,7 @@ use crate::{body, BoxError}; use bytes::{buf::Chain, Buf, Bytes, BytesMut}; use http::{ header::{self, HeaderMap, HeaderName, HeaderValue}, - StatusCode, Version, + StatusCode, }; use http_body::{ combinators::{MapData, MapErr}, @@ -136,14 +136,6 @@ impl IntoResponse for StatusCode { } } -impl IntoResponse for Version { - fn into_response(self) -> Response { - let mut res = ().into_response(); - *res.version_mut() = self; - res - } -} - impl IntoResponse for () { fn into_response(self) -> Response { Empty::new().into_response() @@ -384,30 +376,6 @@ where } } -impl IntoResponse for (Version, R) -where - R: IntoResponse, -{ - fn into_response(self) -> Response { - let mut res = self.1.into_response(); - *res.version_mut() = self.0; - res - } -} - -impl IntoResponse for (Version, StatusCode, R) -where - R: IntoResponse, -{ - fn into_response(self) -> Response { - let (version, status, res) = self; - let mut res = res.into_response(); - *res.version_mut() = version; - *res.status_mut() = status; - res - } -} - impl IntoResponse for HeaderMap { fn into_response(self) -> Response { let mut res = ().into_response(); @@ -501,34 +469,6 @@ macro_rules! impl_into_response { res } } - - #[allow(non_snake_case)] - impl IntoResponse for (Version, StatusCode, $($ty),*, R) - where - $( $ty: IntoResponseParts, )* - R: IntoResponse, - { - fn into_response(self) -> Response { - let (version, status, $($ty),*, res) = self; - - let res = res.into_response(); - let parts = ResponseParts { res }; - - $( - let parts = match $ty.into_response_parts(parts) { - Ok(parts) => parts, - Err(err) => { - return err.into_response(); - } - }; - )* - - let mut res = parts.res; - *res.version_mut() = version; - *res.status_mut() = status; - res - } - } } } diff --git a/axum/src/docs/response.md b/axum/src/docs/response.md index d0379b07..8cf5fb01 100644 --- a/axum/src/docs/response.md +++ b/axum/src/docs/response.md @@ -149,13 +149,10 @@ async fn all_the_things(uri: Uri) -> impl IntoResponse { In general you can return tuples like: - `(StatusCode, impl IntoResponse)` -- `(Version, impl IntoResponse)` -- `(StatusCode, Version, impl IntoResponse)` - `(T1, .., Tn, impl IntoResponse)` where `T1` to `Tn` all implement [`IntoResponseParts`]. - `(StatusCode, T1, .., Tn, impl IntoResponse)` where `T1` to `Tn` all implement [`IntoResponseParts`]. -- `(StatusCode, Version, T1, .., Tn, impl IntoResponse)` where `T1` to `Tn` all implement [`IntoResponseParts`]. -This means you cannot accidentally override the status, version, or body, as [`IntoResponseParts`] only allows +This means you cannot accidentally override the status or body as [`IntoResponseParts`] only allows setting headers and extensions. Use [`Response`](crate::response::Response) for more low level control: