Struct aws_smithy_runtime::client::http::hyper_014::HyperClientBuilder
source · pub struct HyperClientBuilder { /* private fields */ }
client
and connector-hyper-0-14-x
only.Expand description
Builder for a hyper-backed HttpClient
implementation.
This builder can be used to customize the underlying TCP connector used, as well as hyper client configuration.
§Examples
Construct a Hyper client with the default TLS implementation (rustls). This can be useful when you want to share a Hyper connector between multiple generated Smithy clients.
use aws_smithy_runtime::client::http::hyper_014::HyperClientBuilder;
let http_client = HyperClientBuilder::new().build_https();
// This connector can then be given to a generated service Config
let config = my_service_client::Config::builder()
.endpoint_url("http://localhost:1234")
.http_client(http_client)
.build();
let client = my_service_client::Client::from_conf(config);
§Use a Hyper client with WebPKI roots
A use case for where you may want to use the HyperClientBuilder
is when
setting Hyper client settings that aren’t otherwise exposed by the Config
builder interface. Some examples include changing:
- Hyper client settings
- Allowed TLS cipher suites
- Using an alternative TLS connector library (not the default, rustls)
- CA trust root certificates (illustrated using WebPKI below)
use aws_smithy_runtime::client::http::hyper_014::HyperClientBuilder;
let https_connector = hyper_rustls::HttpsConnectorBuilder::new()
.with_webpki_roots()
.https_only()
.enable_http1()
.enable_http2()
.build();
let http_client = HyperClientBuilder::new().build(https_connector);
// This connector can then be given to a generated service Config
let config = my_service_client::Config::builder()
.endpoint_url("https://example.com")
.http_client(http_client)
.build();
let client = my_service_client::Client::from_conf(config);
Implementations§
source§impl HyperClientBuilder
impl HyperClientBuilder
sourcepub fn hyper_builder(self, hyper_builder: Builder) -> Self
pub fn hyper_builder(self, hyper_builder: Builder) -> Self
Override the Hyper client Builder
used to construct this client.
This enables changing settings like forcing HTTP2 and modifying other default client behavior.
sourcepub fn set_hyper_builder(&mut self, hyper_builder: Option<Builder>) -> &mut Self
pub fn set_hyper_builder(&mut self, hyper_builder: Option<Builder>) -> &mut Self
Override the Hyper client Builder
used to construct this client.
This enables changing settings like forcing HTTP2 and modifying other default client behavior.
sourcepub fn build_https(self) -> SharedHttpClient
Available on crate feature tls-rustls
only.
pub fn build_https(self) -> SharedHttpClient
tls-rustls
only.Create a hyper client with the default rustls HTTPS implementation.
The trusted certificates will be loaded later when this becomes the selected HTTP client for a Smithy client.
sourcepub fn build<C>(self, tcp_connector: C) -> SharedHttpClient
pub fn build<C>(self, tcp_connector: C) -> SharedHttpClient
Create a SharedHttpClient
from this builder and a given connector.
Use build_https
if you don’t want to provide a custom TCP connector.
Trait Implementations§
source§impl Clone for HyperClientBuilder
impl Clone for HyperClientBuilder
source§fn clone(&self) -> HyperClientBuilder
fn clone(&self) -> HyperClientBuilder
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more