Skip to content

A tide middleware that implements rate limiting using governor

License

Notifications You must be signed in to change notification settings

ohmree/tide-governor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tide-governor

A tide middleware that provides rate-limiting functionality backed by governor

Example

use tide_governor::GovernorMiddleware;
use std::env;

#[async_std::main]
async fn main() -> tide::Result<()> {
    let mut app = tide::new();
    app.at("/")
        .with(GovernorMiddleware::per_minute(4)?)
        .get(|_| async move { todo!() });
    app.at("/foo/:bar")
        .with(GovernorMiddleware::per_hour(360)?)
        .put(|_| async move { todo!() });

    app.listen(format!("http://localhost:{}", env::var("PORT")?))
        .await?;
    Ok(())
}

About

A tide middleware that implements rate limiting using governor

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages