Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 640 Bytes

README.md

File metadata and controls

31 lines (22 loc) · 640 Bytes

surf-governor

A rate-limiting middleware for surf

Install

With cargo add installed :

cargo add surf-governor

Documentation

Example

use surf_governor::GovernorMiddleware;
use surf::{Client, Request, http::Method};
use url::Url;

#[async_std::main]
async fn main() -> surf::Result<()> {
    let req = Request::new(Method::Get, Url::parse("https://example.api")?);
    let client = Client::new().with(GovernorMiddleware::per_second(1)?);
    let res = client.send(req).await?;
    Ok(())
}