axum-limit
This crate provides an efficient rate limiting mechanism using token buckets, specifically designed for asynchronous web
applications with a strong focus on extractor-based rate limits.
Features
- Configurable rate limits using extractors, allowing for flexible limit strategies per route.
- Supports various time granularities for rate limits (per second, per minute, per hour, and per day).
- Easily integrates with Axum, using extractors to apply rate limits seamlessly within your application routes.
- Utilizes
DashMapfor concurrent state management across asynchronous tasks.
Example
Here is a basic example showing how to use the crate with Axum routes:
use ;
use ;
async
This example demonstrates setting up a rate limit of 5 requests per second on a specific route. The Limit extractor
automatically enforces these limits based on the incoming requests.
For more comprehensive examples, please check the examples directory in this
repository.