1 1 | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 2 | pub use ::aws_smithy_runtime_api::client::endpoint::EndpointFuture;
|
3 3 | pub use ::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver;
|
4 4 | pub use ::aws_smithy_types::endpoint::Endpoint;
|
5 5 |
|
6 - | /// Interceptor that tracks endpoint override business metric.
|
7 - | #[derive(Debug, Default)]
|
8 - | pub(crate) struct EndpointOverrideFeatureTrackerInterceptor;
|
9 - |
|
10 - | impl ::aws_smithy_runtime_api::client::interceptors::Intercept for EndpointOverrideFeatureTrackerInterceptor {
|
11 - | fn name(&self) -> &'static str {
|
12 - | "EndpointOverrideFeatureTrackerInterceptor"
|
13 - | }
|
14 - |
|
15 - | fn read_before_execution(
|
16 - | &self,
|
17 - | _context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<'_>,
|
18 - | cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
|
19 - | ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
|
20 - | if cfg.load::<::aws_types::endpoint_config::EndpointUrl>().is_some() {
|
21 - | cfg.interceptor_state()
|
22 - | .store_append(::aws_runtime::sdk_feature::AwsSdkFeature::EndpointOverride);
|
23 - | }
|
24 - | ::std::result::Result::Ok(())
|
25 - | }
|
26 - | }
|
27 - |
|
28 6 | #[cfg(test)]
|
29 7 | mod test {
|
30 8 |
|
31 9 | /// For custom endpoint with region not set and fips disabled
|
32 10 | #[test]
|
33 11 | fn test_1() {
|
34 12 | let params = crate::config::endpoint::Params::builder()
|
35 13 | .endpoint("https://example.com".to_string())
|
36 14 | .use_fips(false)
|
37 15 | .build()
|
38 16 | .expect("invalid params");
|
39 17 | let resolver = crate::config::endpoint::DefaultResolver::new();
|
40 18 | let endpoint = resolver.resolve_endpoint(¶ms);
|
41 19 | let endpoint = endpoint.expect("Expected valid endpoint: https://example.com");
|
42 20 | assert_eq!(
|
43 21 | endpoint,
|
44 22 | ::aws_smithy_types::endpoint::Endpoint::builder().url("https://example.com").build()
|
45 23 | );
|
46 24 | }
|
47 25 |
|
48 26 | /// For custom endpoint with fips enabled
|
49 27 | #[test]
|
50 28 | fn test_2() {
|
51 29 | let params = crate::config::endpoint::Params::builder()
|
52 30 | .endpoint("https://example.com".to_string())
|
53 31 | .use_fips(true)
|
54 32 | .build()
|
55 33 | .expect("invalid params");
|
56 34 | let resolver = crate::config::endpoint::DefaultResolver::new();
|
57 35 | let endpoint = resolver.resolve_endpoint(¶ms);
|