Some simplifications

This commit is contained in:
David Pedersen
2021-06-01 08:32:58 +02:00
parent 8582c6fd1f
commit 093ad3622e
4 changed files with 7 additions and 19 deletions
+2 -14
View File
@@ -1,9 +1,9 @@
use crate::Body;
use bytes::Bytes;
use http::{HeaderMap, HeaderValue, Response, StatusCode, header};
use http::{header, HeaderMap, HeaderValue, Response, StatusCode};
use serde::Serialize;
use std::convert::Infallible;
use tower::{util::Either, BoxError};
use tower::util::Either;
pub trait IntoResponse<B> {
fn into_response(self) -> Response<B>;
@@ -174,18 +174,6 @@ impl<B> IntoResponse<B> for BoxIntoResponse<B> {
}
}
impl IntoResponse<Body> for BoxError {
fn into_response(self) -> Response<Body> {
// TODO(david): test for know error types like std::io::Error
// or common errors types from tower and map those more appropriately
Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(self.to_string()))
.unwrap()
}
}
impl<B> IntoResponse<B> for StatusCode
where
B: Default,