Struct aws_sdk_workdocs::middleware::DefaultMiddleware
source · #[non_exhaustive]pub struct DefaultMiddleware;
Expand description
AWS Middleware Stack
This implements the middleware stack for this service. It will:
- Load credentials asynchronously into the property bag
- Sign the request with SigV4
- Resolve an Endpoint for the request
- Add a user agent to the request
Implementations§
source§impl DefaultMiddleware
impl DefaultMiddleware
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new DefaultMiddleware
stack
Note: DefaultMiddleware
holds no state.
Examples found in repository?
src/client.rs (line 5462)
5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472
pub fn from_conf(conf: crate::Config) -> Self {
let retry_config = conf
.retry_config()
.cloned()
.unwrap_or_else(aws_smithy_types::retry::RetryConfig::disabled);
let timeout_config = conf
.timeout_config()
.cloned()
.unwrap_or_else(aws_smithy_types::timeout::TimeoutConfig::disabled);
let sleep_impl = conf.sleep_impl();
if (retry_config.has_retry() || timeout_config.has_timeouts()) && sleep_impl.is_none() {
panic!("An async sleep implementation is required for retries or timeouts to work. \
Set the `sleep_impl` on the Config passed into this function to fix this panic.");
}
let connector = conf.http_connector().and_then(|c| {
let timeout_config = conf
.timeout_config()
.cloned()
.unwrap_or_else(aws_smithy_types::timeout::TimeoutConfig::disabled);
let connector_settings =
aws_smithy_client::http_connector::ConnectorSettings::from_timeout_config(
&timeout_config,
);
c.connector(&connector_settings, conf.sleep_impl())
});
let builder = aws_smithy_client::Builder::new();
let builder = match connector {
// Use provided connector
Some(c) => builder.connector(c),
None => {
#[cfg(any(feature = "rustls", feature = "native-tls"))]
{
// Use default connector based on enabled features
builder.dyn_https_connector(
aws_smithy_client::http_connector::ConnectorSettings::from_timeout_config(
&timeout_config,
),
)
}
#[cfg(not(any(feature = "rustls", feature = "native-tls")))]
{
panic!("No HTTP connector was available. Enable the `rustls` or `native-tls` crate feature or set a connector to fix this.");
}
}
};
let mut builder = builder
.middleware(aws_smithy_client::erase::DynMiddleware::new(
crate::middleware::DefaultMiddleware::new(),
))
.retry_config(retry_config.into())
.operation_timeout_config(timeout_config.into());
builder.set_sleep_impl(sleep_impl);
let client = builder.build();
Self {
handle: std::sync::Arc::new(Handle { client, conf }),
}
}
Trait Implementations§
source§impl Clone for DefaultMiddleware
impl Clone for DefaultMiddleware
source§fn clone(&self) -> DefaultMiddleware
fn clone(&self) -> DefaultMiddleware
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for DefaultMiddleware
impl Debug for DefaultMiddleware
source§impl Default for DefaultMiddleware
impl Default for DefaultMiddleware
source§fn default() -> DefaultMiddleware
fn default() -> DefaultMiddleware
Returns the “default value” for a type. Read more
source§impl<S> Layer<S> for DefaultMiddleware
impl<S> Layer<S> for DefaultMiddleware
§type Service = <Stack<MapRequestLayer<RecursionDetectionStage>, Stack<MapRequestLayer<SigV4SigningStage>, Stack<AsyncMapRequestLayer<CredentialsStage>, Stack<MapRequestLayer<UserAgentStage>, Stack<MapRequestLayer<AwsAuthStage>, Stack<MapRequestLayer<SmithyEndpointStage>, Identity>>>>>> as Layer<S>>::Service
type Service = <Stack<MapRequestLayer<RecursionDetectionStage>, Stack<MapRequestLayer<SigV4SigningStage>, Stack<AsyncMapRequestLayer<CredentialsStage>, Stack<MapRequestLayer<UserAgentStage>, Stack<MapRequestLayer<AwsAuthStage>, Stack<MapRequestLayer<SmithyEndpointStage>, Identity>>>>>> as Layer<S>>::Service
The wrapped service