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.
Tip
Fill every placeholder before you run the prompt. Keep one clear goal per run, then refine with a follow-up if needed.
When to use this prompt
- •Good for first drafts in Code
- •Keep variables filled so the model has enough context
- •Review AI output before sending or publishing