mirror of https://github.com/fafhrd91/actix-web
generalize impl Responder for HttpResponse
This commit is contained in:
parent
85c9b1a263
commit
fb7938854d
|
@ -1,12 +1,9 @@
|
|||
use actix_http::{
|
||||
body::{EitherBody, MessageBody},
|
||||
error::HttpError,
|
||||
header::HeaderMap,
|
||||
header::TryIntoHeaderPair,
|
||||
body::EitherBody, error::HttpError, header::HeaderMap, header::TryIntoHeaderPair,
|
||||
StatusCode,
|
||||
};
|
||||
|
||||
use crate::{BoxError, HttpRequest, HttpResponse, Responder};
|
||||
use crate::{HttpRequest, HttpResponse, Responder};
|
||||
|
||||
/// Allows overriding status code and headers for a [`Responder`].
|
||||
///
|
||||
|
@ -143,7 +140,6 @@ impl<R: Responder> CustomizeResponder<R> {
|
|||
impl<T> Responder for CustomizeResponder<T>
|
||||
where
|
||||
T: Responder,
|
||||
<T::Body as MessageBody>::Error: Into<BoxError>,
|
||||
{
|
||||
type Body = EitherBody<T::Body>;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ use actix_http::{
|
|||
};
|
||||
use bytes::{Bytes, BytesMut};
|
||||
|
||||
use crate::{BoxError, Error, HttpRequest, HttpResponse, HttpResponseBuilder};
|
||||
use crate::{Error, HttpRequest, HttpResponse, HttpResponseBuilder};
|
||||
|
||||
use super::CustomizeResponder;
|
||||
|
||||
|
@ -57,8 +57,11 @@ pub trait Responder {
|
|||
}
|
||||
}
|
||||
|
||||
impl Responder for HttpResponse {
|
||||
type Body = BoxBody;
|
||||
impl<B> Responder for HttpResponse<B>
|
||||
where
|
||||
B: MessageBody + 'static,
|
||||
{
|
||||
type Body = B;
|
||||
|
||||
#[inline]
|
||||
fn respond_to(self, _: &HttpRequest) -> HttpResponse<Self::Body> {
|
||||
|
@ -96,7 +99,6 @@ impl Responder for actix_http::ResponseBuilder {
|
|||
impl<T> Responder for Option<T>
|
||||
where
|
||||
T: Responder,
|
||||
<T::Body as MessageBody>::Error: Into<BoxError>,
|
||||
{
|
||||
type Body = EitherBody<T::Body>;
|
||||
|
||||
|
@ -111,7 +113,6 @@ where
|
|||
impl<T, E> Responder for Result<T, E>
|
||||
where
|
||||
T: Responder,
|
||||
<T::Body as MessageBody>::Error: Into<BoxError>,
|
||||
E: Into<Error>,
|
||||
{
|
||||
type Body = EitherBody<T::Body>;
|
||||
|
|
Loading…
Reference in New Issue