mirror of
https://github.com/kennethreitz/responder.git
synced 2026-06-21 15:00:57 +00:00
61f7f24256
Implements the remaining backlog features:
- Dependency injection: register providers with @api.dependency() and
declare them as view parameters by name. Supports sync/async functions
and generators (post-yield code runs as teardown after the response).
Providers taking a parameter receive the current Request. Resolved at
most once per request; path params take precedence.
- Per-route rate limiting via RateLimiter.limit decorator
- WebSocket before-request hooks can reject connections (closing the
socket skips the handler) and may now be sync functions
Also fixes bugs found along the way:
- float path convertor regex had an unescaped dot, matching garbage
like "1a5" and crashing with a 500
- literal route characters weren't regex-escaped (/file.json matched
/fileXjson)
- BackgroundQueue.results grew without bound; completed futures are
now pruned
- req.media("form") crashed when Content-Type was missing
- custom formats registered on api.formats were ignored; they now
thread through the router to request parsing and response negotiation
- Accept headers matching encode-incapable formats (e.g. form) returned
an empty body; negotiation now falls through to JSON
Performance: Request.url and Request.params are cached; format
registries are no longer rebuilt twice per request.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
200 B
200 B
Backlog
Future Ideas
- OpenAPI 3.1 support
- Pluggable rate limiter backends (e.g. Redis) for multi-process deployments
- Dependency providers with app-lifespan scope (resolved once at startup)