Expand description

Implementation of SmithyConnector for Hyper

The module provides Adapter which enables using a hyper::Client as the connector for a Smithy Client. For most use cases, this shouldn’t need to be used directly, but it is available as an option.

Examples

Construct a Smithy Client with Hyper and Rustls

In the basic case, customers should not need to use this module. A default implementation of Hyper with rustls will be constructed during client creation. However, if you are creating a Smithy Client, directly, use the dyn_https_https() method to match that default behavior:

use aws_smithy_client::Client;

let client = Client::builder()
    .dyn_https_connector(Default::default())
    .middleware(
        // Replace this with your middleware type
        tower::layer::util::Identity::default()
    )
    .build();

Use a Hyper client that uses WebPKI roots

A use case for where you may want to use the Adapter is when settings Hyper client settings that aren’t otherwise exposed by the Client builder interface.

use std::time::Duration; use aws_smithy_client::{Client, conns, hyper_ext}; use aws_smithy_client::erase::DynConnector; use aws_smithy_client::http_connector::ConnectorSettings;

let https_connector = hyper_rustls::HttpsConnectorBuilder::new() .with_webpki_roots() .https_only() .enable_http1() .enable_http2() .build(); let smithy_connector = hyper_ext::Adapter::builder() // Optionally set things like timeouts as well .connector_settings( ConnectorSettings::builder() .connect_timeout(Duration::from_secs(5)) .build() ) .build(https_connector);

// Once you have a Smithy connector, use it to construct a Smithy client: let client = Client::builder() .connector(smithy_connector) .middleware(tower::layer::util::Identity::default()) .build();

Structs