diff --git a/actix-http/src/client/connector.rs b/actix-http/src/client/connector.rs index 804756ce..8a0968f5 100644 --- a/actix-http/src/client/connector.rs +++ b/actix-http/src/client/connector.rs @@ -21,8 +21,18 @@ use openssl::ssl::SslConnector; #[cfg(not(feature = "ssl"))] type SslConnector = (); -/// Http client connector builde instance. -/// `Connector` type uses builder-like pattern for connector service construction. +/// Manages http client network connectivity +/// The `Connector` type uses a builder-like combinator pattern for service +/// construction that finishes by calling the `.finish()` method. +/// +/// ```rust +/// use actix-web::client::Connector; +/// use time::Duration; +/// +/// let connector = Connector::new() +/// .timeout(Duration::from_secs(5)) +/// .finish(); +/// ``` pub struct Connector { connector: T, timeout: Duration, @@ -163,8 +173,10 @@ where self } - /// Finish configuration process and create connector service. - pub fn service( + /// Finish configuration process and create connector service. + /// The Connector builder always concludes by calling `finish()` last in + /// its combinator chain. + pub fn finish( self, ) -> impl Service + Clone { diff --git a/awc/src/builder.rs b/awc/src/builder.rs index dcea5595..ddefed43 100644 --- a/awc/src/builder.rs +++ b/awc/src/builder.rs @@ -31,7 +31,7 @@ impl ClientBuilder { headers: HeaderMap::new(), timeout: Some(Duration::from_secs(5)), connector: RefCell::new(Box::new(ConnectorWrapper( - Connector::new().service(), + Connector::new().finish(), ))), }, } diff --git a/awc/src/lib.rs b/awc/src/lib.rs index 5f9adb46..bd08c3c3 100644 --- a/awc/src/lib.rs +++ b/awc/src/lib.rs @@ -78,7 +78,7 @@ impl Default for Client { fn default() -> Self { Client(Rc::new(ClientConfig { connector: RefCell::new(Box::new(ConnectorWrapper( - Connector::new().service(), + Connector::new().finish(), ))), headers: HeaderMap::new(), timeout: Some(Duration::from_secs(5)), diff --git a/src/lib.rs b/src/lib.rs index 39c054bc..a668b83b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -189,7 +189,6 @@ pub mod client { pub use awc::error::{ ConnectError, InvalidUrl, PayloadError, SendRequestError, WsClientError, }; - pub use awc::{ - test, Client, ClientBuilder, ClientRequest, ClientResponse, Connector, - }; + pub use awc::{test, Client, ClientBuilder, ClientRequest, ClientResponse, + Connector}; }