1
0
mirror of https://github.com/actix/examples synced 2024-12-18 00:13:57 +01:00
examples/middleware/rate-limit
2024-03-11 19:48:01 +00:00
..
src chore: address deprecations 2024-03-11 19:48:01 +00:00
Cargo.toml chore: move and document rate limit middleware 2023-10-29 23:47:02 +00:00
README.md chore: move and document rate limit middleware 2023-10-29 23:47:02 +00:00

Middleware: Rate Limiting

This example showcases two middleware that achieve rate limiting for your API endpoints. One uses a simple leaky-bucket implementation and the other delegates to actix-governor.

Usage

cd middleware/rate-limit
cargo run

Look in src/rate_limit.rs to see the leaky-bucket implementation.

Routes

Calling either of these endpoints too frequently will result in a 429 Too Many Requests response.