use actix_http::body::Body; use actix_http::client::{ClientResponse, ConnectError, Connection, SendRequestError}; use actix_http::{http, RequestHead}; use actix_service::Service; use futures::Future; pub(crate) struct ConnectorWrapper(pub T); pub(crate) trait Connect { fn send_request( &mut self, head: RequestHead, body: Body, ) -> Box>; } impl Connect for ConnectorWrapper where T: Service, T::Response: Connection, ::Future: 'static, T::Future: 'static, { fn send_request( &mut self, head: RequestHead, body: Body, ) -> Box> { Box::new( self.0 // connect to the host .call(head.uri.clone()) .from_err() // send request .and_then(move |connection| connection.send_request(head, body)), ) } }