Back to prompts
Write rate limiting middleware for a [FRAMEWORK] REST API. Requirements: - Framework: [EXPRESS / FASTAPI / GIN / HONO / etc.] - Rate limit strategy: [FIXED WINDOW / SLIDING WINDOW / TOKEN BUCKET] - Limits: [X requests per Y minutes per IP / per API key] - Storage: [IN-MEMORY / REDIS] - Response when limit exceeded: 429 status with Retry-After header - Different limits for: [AUTHENTICATED vs UNAUTHENTICATED users, if applicable] Include: 1. The middleware implementation 2. How to apply it globally and to specific routes 3. Example of setting different limits per route 4. Redis setup instructions if using Redis 5. Testing the rate limiter with a simple script
How to use this prompt
- 1Copy the prompt using the button above.
- 2Open your AI tool (ChatGPT, Claude, Midjourney, etc.)
- 3Paste and customize any variables in the prompt.
- 4Generate your result.