mirror of https://github.com/fafhrd91/actix-web
use localboxfuture alias
This commit is contained in:
parent
5b8d8f44ca
commit
79a84be9a5
|
@ -1,6 +1,5 @@
|
||||||
use std::{
|
use std::{
|
||||||
fmt,
|
fmt,
|
||||||
future::Future,
|
|
||||||
io, net,
|
io, net,
|
||||||
pin::Pin,
|
pin::Pin,
|
||||||
task::{Context, Poll},
|
task::{Context, Poll},
|
||||||
|
@ -14,34 +13,28 @@ use actix_http::{
|
||||||
RequestHead, RequestHeadType, ResponseHead,
|
RequestHead, RequestHeadType, ResponseHead,
|
||||||
};
|
};
|
||||||
use actix_service::Service;
|
use actix_service::Service;
|
||||||
|
use futures_core::future::LocalBoxFuture;
|
||||||
|
|
||||||
use crate::response::ClientResponse;
|
use crate::response::ClientResponse;
|
||||||
|
|
||||||
pub(crate) struct ConnectorWrapper<T>(pub T);
|
pub(crate) struct ConnectorWrapper<T>(pub T);
|
||||||
|
|
||||||
|
type TunnelResponse = (ResponseHead, Framed<BoxedSocket, ClientCodec>);
|
||||||
|
|
||||||
pub(crate) trait Connect {
|
pub(crate) trait Connect {
|
||||||
fn send_request(
|
fn send_request(
|
||||||
&mut self,
|
&mut self,
|
||||||
head: RequestHeadType,
|
head: RequestHeadType,
|
||||||
body: Body,
|
body: Body,
|
||||||
addr: Option<net::SocketAddr>,
|
addr: Option<net::SocketAddr>,
|
||||||
) -> Pin<Box<dyn Future<Output = Result<ClientResponse, SendRequestError>>>>;
|
) -> LocalBoxFuture<'static, Result<ClientResponse, SendRequestError>>;
|
||||||
|
|
||||||
/// Send request, returns Response and Framed
|
/// Send request, returns Response and Framed
|
||||||
fn open_tunnel(
|
fn open_tunnel(
|
||||||
&mut self,
|
&mut self,
|
||||||
head: RequestHead,
|
head: RequestHead,
|
||||||
addr: Option<net::SocketAddr>,
|
addr: Option<net::SocketAddr>,
|
||||||
) -> Pin<
|
) -> LocalBoxFuture<'static, Result<TunnelResponse, SendRequestError>>;
|
||||||
Box<
|
|
||||||
dyn Future<
|
|
||||||
Output = Result<
|
|
||||||
(ResponseHead, Framed<BoxedSocket, ClientCodec>),
|
|
||||||
SendRequestError,
|
|
||||||
>,
|
|
||||||
>,
|
|
||||||
>,
|
|
||||||
>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Connect for ConnectorWrapper<T>
|
impl<T> Connect for ConnectorWrapper<T>
|
||||||
|
@ -58,7 +51,7 @@ where
|
||||||
head: RequestHeadType,
|
head: RequestHeadType,
|
||||||
body: Body,
|
body: Body,
|
||||||
addr: Option<net::SocketAddr>,
|
addr: Option<net::SocketAddr>,
|
||||||
) -> Pin<Box<dyn Future<Output = Result<ClientResponse, SendRequestError>>>> {
|
) -> LocalBoxFuture<'static, Result<ClientResponse, SendRequestError>> {
|
||||||
// connect to the host
|
// connect to the host
|
||||||
let fut = self.0.call(ClientConnect {
|
let fut = self.0.call(ClientConnect {
|
||||||
uri: head.as_ref().uri.clone(),
|
uri: head.as_ref().uri.clone(),
|
||||||
|
@ -79,16 +72,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
head: RequestHead,
|
head: RequestHead,
|
||||||
addr: Option<net::SocketAddr>,
|
addr: Option<net::SocketAddr>,
|
||||||
) -> Pin<
|
) -> LocalBoxFuture<'static, Result<TunnelResponse, SendRequestError>> {
|
||||||
Box<
|
|
||||||
dyn Future<
|
|
||||||
Output = Result<
|
|
||||||
(ResponseHead, Framed<BoxedSocket, ClientCodec>),
|
|
||||||
SendRequestError,
|
|
||||||
>,
|
|
||||||
>,
|
|
||||||
>,
|
|
||||||
> {
|
|
||||||
// connect to the host
|
// connect to the host
|
||||||
let fut = self.0.call(ClientConnect {
|
let fut = self.0.call(ClientConnect {
|
||||||
uri: head.uri.clone(),
|
uri: head.uri.clone(),
|
||||||
|
|
Loading…
Reference in New Issue