pub struct ClientWithMiddleware { /* private fields */ }Expand description
A reqwest::Client wrapped in a middleware chain.
Cloneable (all clones share the same chain and connection pool) and
Debug. Built with ClientBuilder.
Implementations§
Source§impl ClientWithMiddleware
impl ClientWithMiddleware
Sourcepub fn middleware_count(&self) -> usize
pub fn middleware_count(&self) -> usize
The number of middleware registered on this client.
Sourcepub fn with_middleware(self, middleware: Arc<dyn Middleware>) -> Self
pub fn with_middleware(self, middleware: Arc<dyn Middleware>) -> Self
Return a new client with middleware appended inside the
existing chain (closest to the transport).
This is a composition point for clients that were already built
(e.g. crate::Client::inner). When building from scratch, prefer
ClientBuilder::with, which registers middleware outermost-first.
Sourcepub async fn execute(&self, req: Request) -> Result<Response>
pub async fn execute(&self, req: Request) -> Result<Response>
Execute the request through the middleware chain with a fresh, empty per-request extension map.
Sourcepub async fn execute_with_extensions(
&self,
req: Request,
extensions: &mut Extensions,
) -> Result<Response>
pub async fn execute_with_extensions( &self, req: Request, extensions: &mut Extensions, ) -> Result<Response>
Execute the request through the middleware chain, seeding the
per-request extension map with extensions.
The map is shared by every middleware in the chain and survives
across retry attempts of the same logical request; it is the
request-scoped typed map that RequestBuilder::with_extension
populates.
Sourcepub fn get(&self, url: impl Into<String>) -> RequestBuilder
pub fn get(&self, url: impl Into<String>) -> RequestBuilder
Convenience method to make a GET request to a URL.
Sourcepub fn post(&self, url: impl Into<String>) -> RequestBuilder
pub fn post(&self, url: impl Into<String>) -> RequestBuilder
Convenience method to make a POST request to a URL.
Sourcepub fn put(&self, url: impl Into<String>) -> RequestBuilder
pub fn put(&self, url: impl Into<String>) -> RequestBuilder
Convenience method to make a PUT request to a URL.
Sourcepub fn patch(&self, url: impl Into<String>) -> RequestBuilder
pub fn patch(&self, url: impl Into<String>) -> RequestBuilder
Convenience method to make a PATCH request to a URL.
Sourcepub fn head(&self, url: impl Into<String>) -> RequestBuilder
pub fn head(&self, url: impl Into<String>) -> RequestBuilder
Convenience method to make a HEAD request to a URL.
Sourcepub fn delete(&self, url: impl Into<String>) -> RequestBuilder
pub fn delete(&self, url: impl Into<String>) -> RequestBuilder
Convenience method to make a DELETE request to a URL.