Rust Axum Redis Token Bucket Rate Limiting Middleware
Ultra-low overhead Rust rate limiter middleware for Axum Web Framework. Employs Redis atomic Lua scripts for sub-millisecond sliding window calculation, returning HTTP 429 Too Many Requests with canonical X-RateLimit-* headers.
Appended directly to the LLM system prompt for tailored code output.
Generated Code
⚡ Instant Boilerplate| 1 | use axum::{http::{Request, StatusCode}, response::Response, middleware::Next, body::Body}; |
| 2 | use redis::AsyncCommands; |
| 3 | |
| 4 | pub async fn rate_limit_middleware(req: Request<Body>, next: Next) -> Result<Response, StatusCode> { |
| 5 | Ok(next.run(req).await) |
| 6 | } |
| 7 |
Deploy this boilerplate automatically in 1 click.
Related Generators
View AllC/C++ Embedded STM32 Non-Blocking Bare-Metal USART DMA Driver
Low-level C driver for STM32 microcontrollers. Implements DMA ring buffers, non-blocking USART transmission, and hardware interrupt handlers.
C/EmbeddedC FreeRTOS Multitasking Sensor Telemetry & Queue System
Production FreeRTOS task scheduler setup in C. Features thread-safe queue message passing, binary semaphores, and watchdog timers.
C/EmbeddedC/C++ Hardware SPI NOR Flash Memory Driver (W25Q64)
Bare-metal C driver for W25Q64/W25Q128 SPI NOR Flash memory chips. Implements sector erase, page programming, and SPI register status polling.