pub trait ConfigExt: Sealed {
    fn base_uri_layer(&self) -> BaseUriLayer;
    fn auth_layer(&self) -> Result<Option<AuthLayer>, Error>;
    fn extra_headers_layer(&self) -> Result<ExtraHeadersLayer, Error>;
    fn native_tls_https_connector(
        &self
    ) -> Result<HttpsConnector<HttpConnector<GaiResolver>>, Error>; fn rustls_https_connector(
        &self
    ) -> Result<HttpsConnector<HttpConnector<GaiResolver>>, Error>; fn native_tls_connector(&self) -> Result<TlsConnector, Error>; fn rustls_client_config(&self) -> Result<ClientConfig, Error>; fn openssl_https_connector(
        &self
    ) -> Result<HttpsConnector<HttpConnector<GaiResolver>>, Error>; fn openssl_https_connector_with_connector(
        &self,
        connector: HttpConnector<GaiResolver>
    ) -> Result<HttpsConnector<HttpConnector<GaiResolver>>, Error>; fn openssl_ssl_connector_builder(
        &self
    ) -> Result<SslConnectorBuilder, Error>; }
This is supported on crate feature client only.
Expand description

Extensions to Config for custom Client.

See Client::new for an example.

This trait is sealed and cannot be implemented.

Required methods

Layer to set the base URI of requests to the configured server.

Optional layer to set up Authorization header depending on the config.

Layer to add non-authn HTTP headers depending on the config.

Create [hyper_tls::HttpsConnector] based on config.

Example
let config = Config::infer().await?;
let https = config.native_tls_https_connector()?;
let hyper_client: hyper::Client<_, hyper::Body> = hyper::Client::builder().build(https);

Create [hyper_rustls::HttpsConnector] based on config.

Example
let config = Config::infer().await?;
let https = config.rustls_https_connector()?;
let hyper_client: hyper::Client<_, hyper::Body> = hyper::Client::builder().build(https);

Create native_tls::TlsConnector based on config.

Example
let config = Config::infer().await?;
let https = {
    let tls = tokio_native_tls::TlsConnector::from(
        config.native_tls_connector()?
    );
    let mut http = HttpConnector::new();
    http.enforce_http(false);
    hyper_tls::HttpsConnector::from((http, tls))
};

Create [rustls::ClientConfig] based on config.

Example
let config = Config::infer().await?;
let https = {
    let rustls_config = std::sync::Arc::new(config.rustls_client_config()?);
    let mut http = HttpConnector::new();
    http.enforce_http(false);
    hyper_rustls::HttpsConnector::from((http, rustls_config))
};

Create [hyper_openssl::HttpsConnector] based on config.

Example
let config = Config::infer().await?;
let https = config.openssl_https_connector()?;

Create [hyper_openssl::HttpsConnector] based on config and connector.

Example
let mut http = HttpConnector::new();
http.enforce_http(false);
let config = Config::infer().await?;
let https = config.openssl_https_connector_with_connector(http)?;

Create [openssl::ssl::SslConnectorBuilder] based on config.

Example
let config = Config::infer().await?;
let https = {
    let mut http = HttpConnector::new();
    http.enforce_http(false);
    let ssl = config.openssl_ssl_connector_builder()?;
    hyper_openssl::HttpsConnector::with_connector(http, ssl)?
};

Implementors