Files
responder/docs
kennethreitz 61f7f24256 Add dependency injection, per-route rate limiting, and WebSocket short-circuit
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>
2026-06-11 21:07:29 -04:00
..
2018-10-11 12:59:27 -04:00
2018-10-11 12:59:27 -04:00