Expand description
Middleware to rate-limit requests built on reqwest_middleware
.
You’re expected to provide your own RateLimiter
implementation.
§Example
use reqwest_middleware::{ClientBuilder, ClientWithMiddleware};
use std::future::Future;
struct RateLimiter;
impl reqwest_ratelimit::RateLimiter for RateLimiter {
async fn acquire_permit(&self) {
// noop
}
}
async fn run() {
let client = ClientBuilder::new(reqwest::Client::new())
.with(reqwest_ratelimit::all(RateLimiter))
.build();
client.get("https://crates.io").send().await.unwrap();
}
Structs§
- Middleware
- Request rate-limiting middleware.
Traits§
- Rate
Limiter - Request rate limiter.
Functions§
- all
- Creates a new
Middleware
rate-limiting all requests using the providedRateLimiter
.