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 + |
|
6 28 | #[cfg(test)]
|
7 29 | mod test {
|
8 30 |
|
9 31 | /// For custom endpoint with region not set and fips disabled
|
10 32 | #[test]
|
11 33 | fn test_1() {
|
12 34 | let params = crate::config::endpoint::Params::builder()
|
13 35 | .endpoint("https://example.com".to_string())
|
14 36 | .use_fips(false)
|
15 37 | .build()
|
16 38 | .expect("invalid params");
|
17 39 | let resolver = crate::config::endpoint::DefaultResolver::new();
|
18 40 | let endpoint = resolver.resolve_endpoint(¶ms);
|
19 41 | let endpoint = endpoint.expect("Expected valid endpoint: https://example.com");
|
20 42 | assert_eq!(
|
21 43 | endpoint,
|
22 44 | ::aws_smithy_types::endpoint::Endpoint::builder().url("https://example.com").build()
|
23 45 | );
|
24 46 | }
|
25 47 |
|
26 48 | /// For custom endpoint with fips enabled
|
27 49 | #[test]
|
28 50 | fn test_2() {
|
29 51 | let params = crate::config::endpoint::Params::builder()
|
30 52 | .endpoint("https://example.com".to_string())
|
31 53 | .use_fips(true)
|
32 54 | .build()
|
33 55 | .expect("invalid params");
|
34 56 | let resolver = crate::config::endpoint::DefaultResolver::new();
|
35 57 | let endpoint = resolver.resolve_endpoint(¶ms);
|