Move Headers into axum

This commit is contained in:
David Pedersen
2022-01-23 20:25:12 +01:00
parent bf83f34617
commit d4849820ce
4 changed files with 22 additions and 21 deletions
+2 -14
View File
@@ -19,11 +19,6 @@ use http_body::{
};
use std::{borrow::Cow, convert::Infallible, iter};
mod headers;
#[doc(inline)]
pub use self::headers::Headers;
/// Type alias for [`http::Response`] whose body type defaults to [`BoxBody`], the most common body
/// type used with axum.
pub type Response<T = BoxBody> = http::Response<T>;
@@ -356,17 +351,10 @@ impl IntoResponse for StatusCode {
}
}
impl<H> IntoResponse for H
where
H: IntoResponseHeaders,
{
impl IntoResponse for HeaderMap {
fn into_response(self) -> Response {
let mut res = Response::new(boxed(Empty::new()));
if let Err(e) = try_extend_headers(res.headers_mut(), self.into_headers()) {
return e;
}
*res.headers_mut() = self;
res
}
}