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::{
|
use actix_http::{
|
||||||
body::{EitherBody, MessageBody},
|
body::EitherBody, error::HttpError, header::HeaderMap, header::TryIntoHeaderPair,
|
||||||
error::HttpError,
|
|
||||||
header::HeaderMap,
|
|
||||||
header::TryIntoHeaderPair,
|
|
||||||
StatusCode,
|
StatusCode,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{BoxError, HttpRequest, HttpResponse, Responder};
|
use crate::{HttpRequest, HttpResponse, Responder};
|
||||||
|
|
||||||
/// Allows overriding status code and headers for a [`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>
|
impl<T> Responder for CustomizeResponder<T>
|
||||||
where
|
where
|
||||||
T: Responder,
|
T: Responder,
|
||||||
<T::Body as MessageBody>::Error: Into<BoxError>,
|
|
||||||
{
|
{
|
||||||
type Body = EitherBody<T::Body>;
|
type Body = EitherBody<T::Body>;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ use actix_http::{
|
||||||
};
|
};
|
||||||
use bytes::{Bytes, BytesMut};
|
use bytes::{Bytes, BytesMut};
|
||||||
|
|
||||||
use crate::{BoxError, Error, HttpRequest, HttpResponse, HttpResponseBuilder};
|
use crate::{Error, HttpRequest, HttpResponse, HttpResponseBuilder};
|
||||||
|
|
||||||
use super::CustomizeResponder;
|
use super::CustomizeResponder;
|
||||||
|
|
||||||
|
@ -57,8 +57,11 @@ pub trait Responder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Responder for HttpResponse {
|
impl<B> Responder for HttpResponse<B>
|
||||||
type Body = BoxBody;
|
where
|
||||||
|
B: MessageBody + 'static,
|
||||||
|
{
|
||||||
|
type Body = B;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn respond_to(self, _: &HttpRequest) -> HttpResponse<Self::Body> {
|
fn respond_to(self, _: &HttpRequest) -> HttpResponse<Self::Body> {
|
||||||
|
@ -96,7 +99,6 @@ impl Responder for actix_http::ResponseBuilder {
|
||||||
impl<T> Responder for Option<T>
|
impl<T> Responder for Option<T>
|
||||||
where
|
where
|
||||||
T: Responder,
|
T: Responder,
|
||||||
<T::Body as MessageBody>::Error: Into<BoxError>,
|
|
||||||
{
|
{
|
||||||
type Body = EitherBody<T::Body>;
|
type Body = EitherBody<T::Body>;
|
||||||
|
|
||||||
|
@ -111,7 +113,6 @@ where
|
||||||
impl<T, E> Responder for Result<T, E>
|
impl<T, E> Responder for Result<T, E>
|
||||||
where
|
where
|
||||||
T: Responder,
|
T: Responder,
|
||||||
<T::Body as MessageBody>::Error: Into<BoxError>,
|
|
||||||
E: Into<Error>,
|
E: Into<Error>,
|
||||||
{
|
{
|
||||||
type Body = EitherBody<T::Body>;
|
type Body = EitherBody<T::Body>;
|
||||||
|
|
Loading…
Reference in New Issue