#[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 4438)
4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448
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