mirror of https://github.com/fafhrd91/actix-web
impl IntoFuture for HttpResponse for all body types
This commit is contained in:
parent
cc7145d41d
commit
4e7ee20bab
|
@ -92,6 +92,7 @@ mime = "0.3"
|
|||
once_cell = "1.5"
|
||||
pin-project-lite = "0.2.7"
|
||||
regex = "1.5.5"
|
||||
rustversion = "1"
|
||||
serde = "1.0"
|
||||
serde_json = "1.0"
|
||||
serde_urlencoded = "0.7"
|
||||
|
|
|
@ -333,12 +333,14 @@ impl<B> From<HttpResponse<B>> for Response<B> {
|
|||
#[cfg(test)]
|
||||
mod response_fut_impl {
|
||||
use std::{
|
||||
future::Future,
|
||||
future::{Future, IntoFuture},
|
||||
mem,
|
||||
pin::Pin,
|
||||
task::{Context, Poll},
|
||||
};
|
||||
|
||||
use actix_utils::future::{ready, Ready};
|
||||
|
||||
use super::*;
|
||||
|
||||
// Future is only implemented for BoxBody payload type because it's the most useful for making
|
||||
|
@ -361,6 +363,18 @@ mod response_fut_impl {
|
|||
)))
|
||||
}
|
||||
}
|
||||
|
||||
impl<B> IntoFuture for HttpResponse<B> {
|
||||
type Output = Result<Response<B>, Error>;
|
||||
type IntoFuture = Ready<Self::Output>;
|
||||
|
||||
fn into_future(self) -> Self::IntoFuture {
|
||||
ready(match self.error.take() {
|
||||
Some(err) => Err(err),
|
||||
None => Ok(self.res),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<B> Responder for HttpResponse<B>
|
||||
|
|
Loading…
Reference in New Issue