mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-24 08:22:59 +01:00
add IntoFuture impl for Response and ResponseBuilder
This commit is contained in:
parent
2d0495093c
commit
b535adf637
@ -81,7 +81,7 @@ macro_rules! test_header {
|
|||||||
let a: Vec<Vec<u8>> = raw.iter().map(|x| x.to_vec()).collect();
|
let a: Vec<Vec<u8>> = raw.iter().map(|x| x.to_vec()).collect();
|
||||||
let mut req = test::TestRequest::default();
|
let mut req = test::TestRequest::default();
|
||||||
for item in a {
|
for item in a {
|
||||||
req = req.header(HeaderField::name(), item);
|
req = req.header(HeaderField::name(), item).take();
|
||||||
}
|
}
|
||||||
let req = req.finish();
|
let req = req.finish();
|
||||||
let value = HeaderField::parse(&req);
|
let value = HeaderField::parse(&req);
|
||||||
@ -108,7 +108,7 @@ macro_rules! test_header {
|
|||||||
let a: Vec<Vec<u8>> = $raw.iter().map(|x| x.to_vec()).collect();
|
let a: Vec<Vec<u8>> = $raw.iter().map(|x| x.to_vec()).collect();
|
||||||
let mut req = test::TestRequest::default();
|
let mut req = test::TestRequest::default();
|
||||||
for item in a {
|
for item in a {
|
||||||
req = req.header(HeaderField::name(), item);
|
req.header(HeaderField::name(), item);
|
||||||
}
|
}
|
||||||
let req = req.finish();
|
let req = req.finish();
|
||||||
let val = HeaderField::parse(&req);
|
let val = HeaderField::parse(&req);
|
||||||
|
@ -4,6 +4,7 @@ use std::{fmt, str};
|
|||||||
|
|
||||||
use bytes::{BufMut, Bytes, BytesMut};
|
use bytes::{BufMut, Bytes, BytesMut};
|
||||||
use cookie::{Cookie, CookieJar};
|
use cookie::{Cookie, CookieJar};
|
||||||
|
use futures::future::{ok, FutureResult, IntoFuture};
|
||||||
use futures::Stream;
|
use futures::Stream;
|
||||||
use http::header::{self, HeaderName, HeaderValue};
|
use http::header::{self, HeaderName, HeaderValue};
|
||||||
use http::{Error as HttpError, HeaderMap, HttpTryFrom, StatusCode};
|
use http::{Error as HttpError, HeaderMap, HttpTryFrom, StatusCode};
|
||||||
@ -276,6 +277,16 @@ impl<B: MessageBody> fmt::Debug for Response<B> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl IntoFuture for Response {
|
||||||
|
type Item = Response;
|
||||||
|
type Error = Error;
|
||||||
|
type Future = FutureResult<Response, Error>;
|
||||||
|
|
||||||
|
fn into_future(self) -> Self::Future {
|
||||||
|
ok(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct CookieIter<'a> {
|
pub struct CookieIter<'a> {
|
||||||
iter: header::ValueIter<'a, HeaderValue>,
|
iter: header::ValueIter<'a, HeaderValue>,
|
||||||
}
|
}
|
||||||
@ -679,6 +690,16 @@ fn parts<'a>(
|
|||||||
parts.as_mut()
|
parts.as_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl IntoFuture for ResponseBuilder {
|
||||||
|
type Item = Response;
|
||||||
|
type Error = Error;
|
||||||
|
type Future = FutureResult<Response, Error>;
|
||||||
|
|
||||||
|
fn into_future(mut self) -> Self::Future {
|
||||||
|
ok(self.finish())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Helper converters
|
/// Helper converters
|
||||||
impl<I: Into<Response>, E: Into<Error>> From<Result<I, E>> for Response {
|
impl<I: Into<Response>, E: Into<Error>> From<Result<I, E>> for Response {
|
||||||
fn from(res: Result<I, E>) -> Self {
|
fn from(res: Result<I, E>) -> Self {
|
||||||
|
Loading…
Reference in New Issue
Block a user