Struct aws_smithy_runtime::client::http::hyper_014::HyperClientBuilder
source · pub struct HyperClientBuilder { /* private fields */ }
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<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.
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 moresource§impl Debug for HyperClientBuilder
impl Debug for HyperClientBuilder
source§impl Default for HyperClientBuilder
impl Default for HyperClientBuilder
source§fn default() -> HyperClientBuilder
fn default() -> HyperClientBuilder
Auto Trait Implementations§
impl Freeze for HyperClientBuilder
impl !RefUnwindSafe for HyperClientBuilder
impl Send for HyperClientBuilder
impl Sync for HyperClientBuilder
impl Unpin for HyperClientBuilder
impl !UnwindSafe for HyperClientBuilder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)