Skip to content

Commit 04aa4c8

Browse files
authored
Fix docs in hyper_014 module (#3282)
Moves the doc comments from HyperConnector to HyperClientBuilder where they're more relevant, and fixes the examples. This fix is for awslabs/aws-sdk-rust#986. ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
1 parent 48b4506 commit 04aa4c8

File tree

2 files changed

+64
-47
lines changed

2 files changed

+64
-47
lines changed

CHANGELOG.next.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,15 @@ message = "Improve the error messages for when auth fails to select an auth sche
6161
references = ["smithy-rs#3277"]
6262
meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client" }
6363
author = "jdisanti"
64+
65+
[[aws-sdk-rust]]
66+
message = "Fix documentation and examples on HyperConnector and HyperClientBuilder."
67+
references = ["aws-sdk-rust#986", "smithy-rs#3282"]
68+
meta = { "breaking" = false, "tada" = false, "bug" = false }
69+
author = "jdisanti"
70+
71+
[[smithy-rs]]
72+
message = "Fix documentation and examples on HyperConnector and HyperClientBuilder."
73+
references = ["smithy-rs#3282"]
74+
meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client" }
75+
author = "jdisanti"

rust-runtime/aws-smithy-runtime/src/client/http/hyper_014.rs

Lines changed: 52 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -132,53 +132,9 @@ pub fn default_client() -> Option<SharedHttpClient> {
132132
///
133133
/// This connector also implements socket connect and read timeouts.
134134
///
135-
/// # Examples
136-
///
137-
/// Construct a `HyperConnector` with the default TLS implementation (rustls).
138-
/// This can be useful when you want to share a Hyper connector between multiple
139-
/// generated Smithy clients.
140-
///
141-
/// ```no_run,ignore
142-
/// use aws_smithy_runtime::client::connectors::hyper_connector::{DefaultHttpsTcpConnector, HyperConnector};
143-
///
144-
/// let hyper_connector = HyperConnector::builder().build(DefaultHttpsTcpConnector::new());
145-
///
146-
/// // This connector can then be given to a generated service Config
147-
/// let config = my_service_client::Config::builder()
148-
/// .endpoint_url("http://localhost:1234")
149-
/// .http_connector(hyper_connector)
150-
/// .build();
151-
/// let client = my_service_client::Client::from_conf(config);
152-
/// ```
153-
///
154-
/// ## Use a Hyper client with WebPKI roots
155-
///
156-
/// A use case for where you may want to use the [`HyperConnector`] is when setting Hyper client settings
157-
/// that aren't otherwise exposed by the `Config` builder interface. Some examples include changing:
158-
///
159-
/// - Hyper client settings
160-
/// - Allowed TLS cipher suites
161-
/// - Using an alternative TLS connector library (not the default, rustls)
162-
/// - CA trust root certificates (illustrated using WebPKI below)
163-
///
164-
/// ```no_run,ignore
165-
/// use aws_smithy_runtime::client::connectors::hyper_connector::HyperConnector;
166-
///
167-
/// let https_connector = hyper_rustls::HttpsConnectorBuilder::new()
168-
/// .with_webpki_roots()
169-
/// .https_only()
170-
/// .enable_http1()
171-
/// .enable_http2()
172-
/// .build();
173-
/// let hyper_connector = HyperConnector::builder().build(https_connector);
174-
///
175-
/// // This connector can then be given to a generated service Config
176-
/// let config = my_service_client::Config::builder()
177-
/// .endpoint_url("https://example.com")
178-
/// .http_connector(hyper_connector)
179-
/// .build();
180-
/// let client = my_service_client::Client::from_conf(config);
181-
/// ```
135+
/// This shouldn't be used directly in most cases.
136+
/// See the docs on [`HyperClientBuilder`] for examples of how
137+
/// to customize the Hyper client.
182138
#[derive(Debug)]
183139
pub struct HyperConnector {
184140
adapter: Box<dyn HttpConnector>,
@@ -533,6 +489,55 @@ where
533489
///
534490
/// This builder can be used to customize the underlying TCP connector used, as well as
535491
/// hyper client configuration.
492+
///
493+
/// # Examples
494+
///
495+
/// Construct a Hyper client with the default TLS implementation (rustls).
496+
/// This can be useful when you want to share a Hyper connector between multiple
497+
/// generated Smithy clients.
498+
///
499+
/// ```no_run,ignore
500+
/// use aws_smithy_runtime::client::http::hyper_014::HyperClientBuilder;
501+
///
502+
/// let http_client = HyperClientBuilder::new().build_https();
503+
///
504+
/// // This connector can then be given to a generated service Config
505+
/// let config = my_service_client::Config::builder()
506+
/// .endpoint_url("http://localhost:1234")
507+
/// .http_client(http_client)
508+
/// .build();
509+
/// let client = my_service_client::Client::from_conf(config);
510+
/// ```
511+
///
512+
/// ## Use a Hyper client with WebPKI roots
513+
///
514+
/// A use case for where you may want to use the [`HyperClientBuilder`] is when
515+
/// setting Hyper client settings that aren't otherwise exposed by the `Config`
516+
/// builder interface. Some examples include changing:
517+
///
518+
/// - Hyper client settings
519+
/// - Allowed TLS cipher suites
520+
/// - Using an alternative TLS connector library (not the default, rustls)
521+
/// - CA trust root certificates (illustrated using WebPKI below)
522+
///
523+
/// ```no_run,ignore
524+
/// use aws_smithy_runtime::client::http::hyper_014::HyperClientBuilder;
525+
///
526+
/// let https_connector = hyper_rustls::HttpsConnectorBuilder::new()
527+
/// .with_webpki_roots()
528+
/// .https_only()
529+
/// .enable_http1()
530+
/// .enable_http2()
531+
/// .build();
532+
/// let http_client = HyperClientBuilder::new().build(https_connector);
533+
///
534+
/// // This connector can then be given to a generated service Config
535+
/// let config = my_service_client::Config::builder()
536+
/// .endpoint_url("https://example.com")
537+
/// .http_client(http_client)
538+
/// .build();
539+
/// let client = my_service_client::Client::from_conf(config);
540+
/// ```
536541
#[derive(Clone, Default, Debug)]
537542
pub struct HyperClientBuilder {
538543
client_builder: Option<hyper_0_14::client::Builder>,

0 commit comments

Comments
 (0)