reqwest_replay/lib.rs
1//! Transparent HTTP request/response recording and replay for `reqwest`.
2//!
3//! This crate provides a middleware layer for `reqwest` that automatically records
4//! each HTTP request and its response to separate files on disk. When an identical request
5//! is made again, the stored response is returned instantly, skipping the network.
6//!
7//! # Example
8//! ```rust
9//! use reqwest_replay::ClientBuilder;
10//! use serde_json::json;
11//!
12//! #[tokio::main]
13//! async fn main() {
14//! let client = ClientBuilder::new().cache_dir("docs_cache").build();
15//!
16//! // First request - will be fetched from the network
17//! let response = client
18//! .post("https://httpbin.org/post")
19//! .json(&json!({ "query": "example" }))
20//! .send()
21//! .await
22//! .unwrap();
23//!
24//! println!("First request status: {}", response.status());
25//!
26//! // Identical second request - will be served from cache file
27//! let cached_response = client
28//! .post("https://httpbin.org/post")
29//! .json(&json!({ "query": "example" }))
30//! .send()
31//! .await
32//! .unwrap();
33//!
34//! println!("Cached response status: {}", cached_response.status());
35//! }
36//! ```
37//!
38
39pub mod middleware;
40pub use middleware::ClientBuilder;