Quality of life improvements

This commit is contained in:
David Pedersen
2021-06-01 14:52:18 +02:00
parent 90b9dffce7
commit ea582ab8d9
6 changed files with 42 additions and 125 deletions
+1 -17
View File
@@ -5,17 +5,9 @@ use serde::Serialize;
use std::convert::Infallible;
use tower::util::Either;
// TODO(david): can we change this to not be generic over the body and just use hyper::Body?
pub trait IntoResponse<B> {
fn into_response(self) -> Response<B>;
// TODO(david): remove this an return return `Response<B>` instead. That is what this method
// does anyway.
fn boxed(self) -> BoxIntoResponse<B>
where
Self: Sized + 'static,
{
BoxIntoResponse(self.into_response())
}
}
impl<B> IntoResponse<B> for ()
@@ -171,14 +163,6 @@ where
}
}
pub struct BoxIntoResponse<B>(Response<B>);
impl<B> IntoResponse<B> for BoxIntoResponse<B> {
fn into_response(self) -> Response<B> {
self.0
}
}
impl<B> IntoResponse<B> for StatusCode
where
B: Default,