pub trait Middleware:
'static
+ Send
+ Sync {
// Required method
fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: Request,
extensions: &'life1 mut Extensions,
next: Next<'life2>,
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
}Expand description
Async middleware that wraps a ClientWithMiddleware.
Implement handle to inspect or rewrite the request before it travels
inward, and/or the response (or error) on the way back out. Call
Next::run to continue the chain; returning without calling it
short-circuits everything inward (including the transport).
The extensions argument is a per-logical-request typed map shared by
every middleware in the chain (and across all retry attempts of one
logical request); use it for cross-middleware state. Request-scoped
typed data set via RequestBuilder::with_extension arrives in this
map.
Required Methods§
Sourcefn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: Request,
extensions: &'life1 mut Extensions,
next: Next<'life2>,
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: Request,
extensions: &'life1 mut Extensions,
next: Next<'life2>,
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Handle the request, optionally calling next to continue the chain.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".