mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-27 00:00:24 +02:00
Some simplifications
This commit is contained in:
+2
-14
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user