Build a lightweight rate-limiting ASGI middleware using starlette primitives. Implement a class called…
Build a lightweight rate-limiting ASGI middleware using starlette primitives. Implement a class called…: a task in repo2rlenv-code-instruct (Harbor dataset). Requirements: - Subclass or wrap using starlette.middleware.base.BaseHTTPMiddleware . - Extract the client IP from the incoming…
The task
Requirements: - Subclass or wrap using `starlette.middleware.base.BaseHTTPMiddleware`. - Extract the client IP from the incoming `starlette.requests.Request`. - Track per-IP request counts using an in-memory store. - If a client exceeds `max_requests` within `window_seconds`, return a…
Part of FineEnvs/repo2rlenv-code-instruct.