MCPcopy Index your code
hub / github.com/TrueLayer/reqwest-middleware

github.com/TrueLayer/reqwest-middleware @reqwest-retry-v0.9.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release reqwest-retry-v0.9.1 ↗ · + Follow
138 symbols 288 edges 18 files 74 documented · 54% updated 52d agoreqwest-tracing-v0.7.1 · 2026-05-19★ 37829 open issues

Browse by type

Functions 111 Types & classes 27
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

reqwest-middleware

A crate implementing a wrapper around reqwest to allow for client middleware chains.

Crates.io Docs.rs CI Coverage Status

This crate provides functionality for building and running middleware but no middleware implementations. This repository also contains a couple of useful concrete middleware crates:

Note about browser support: automated tests targeting wasm are disabled. The crate may work with wasm but wasm support is unmaintained. PRs improving wasm are still welcome but you'd need to reintroduce the tests and get them passing before we'd merge it (see https://github.com/TrueLayer/reqwest-middleware/pull/105).

Overview

The reqwest-middleware client exposes the same interface as a plain reqwest client, but ClientBuilder exposes functionality to attach middleware:

# Cargo.toml
# ...
[dependencies]
reqwest = "0.13"
reqwest-middleware = "0.5"
reqwest-retry = "0.9"
reqwest-tracing = "0.6"
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
use reqwest_middleware::{ClientBuilder, ClientWithMiddleware};
use reqwest_retry::{RetryTransientMiddleware, policies::ExponentialBackoff};
use reqwest_tracing::TracingMiddleware;

#[tokio::main]
async fn main() {
    // Retry up to 3 times with increasing intervals between attempts.
    let retry_policy = ExponentialBackoff::builder().build_with_max_retries(3);
    let client = ClientBuilder::new(reqwest::Client::new())
        // Trace HTTP requests. See the tracing crate to make use of these traces.
        .with(TracingMiddleware::default())
        // Retry failed requests.
        .with(RetryTransientMiddleware::new_with_policy(retry_policy))
        .build();
    run(client).await;
}

async fn run(client: ClientWithMiddleware) {
    client
        .get("https://truelayer.com")
        .header("foo", "bar")
        .send()
        .await
        .unwrap();
}

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Third-party middleware

The following third-party middleware use reqwest-middleware:

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Shape

Method 87
Function 24
Class 20
Interface 4
Enum 3

Languages

Rust100%

Modules by API surface

reqwest-middleware/src/client.rs42 symbols
reqwest-tracing/src/reqwest_otel_span_builder.rs22 symbols
reqwest-middleware/src/error.rs16 symbols
reqwest-retry/tests/all/helpers/simple_server.rs11 symbols
reqwest-tracing/src/otel.rs8 symbols
reqwest-retry/tests/all/retry.rs8 symbols
reqwest-retry/src/retryable_strategy.rs7 symbols
reqwest-retry/src/middleware.rs6 symbols
reqwest-tracing/src/middleware.rs5 symbols
reqwest-middleware/src/middleware.rs5 symbols
reqwest-retry/src/retryable.rs3 symbols
reqwest-middleware/src/req_init.rs3 symbols

For agents

$ claude mcp add reqwest-middleware \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page