mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
updated Connector docs and renamed service() to finish() (#757)
* added Connector to actix-web::client namespace * updated Connector, renaming service() to finish() and adding docs * added doc for finish method on Connector
This commit is contained in:
parent
b6dacaa23a
commit
18593d8476
@ -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<T, U> {
|
||||
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<Request = Uri, Response = impl Connection, Error = ConnectError> + Clone
|
||||
{
|
||||
|
@ -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(),
|
||||
))),
|
||||
},
|
||||
}
|
||||
|
@ -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)),
|
||||
|
@ -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};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user