mirror of
https://github.com/kennethreitz/responder.git
synced 2026-06-05 14:50:19 +00:00
4f02016ed6
- Add docstrings to all undocumented public methods across API, Request, Response, Router, Route, BackgroundQueue, and related classes - Expand api.rst with autodoc sections for RouteGroup, BackgroundQueue, QueryDict, and RateLimiter - Update starlette dependency to >=1.0 - Drop Python 3.9 support (required by Starlette 1.0), minimum is now 3.10 - Bump version to 3.4.0 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
100 lines
2.2 KiB
ReStructuredText
100 lines
2.2 KiB
ReStructuredText
API Reference
|
|
=============
|
|
|
|
This page documents Responder's public Python API. For usage examples
|
|
and explanations, see the :doc:`quickstart` and :doc:`tour`.
|
|
|
|
|
|
The API Class
|
|
-------------
|
|
|
|
The central object of every Responder application. It holds your routes,
|
|
middleware, templates, and configuration. Create one at the top of your
|
|
module and use it to define your entire web service.
|
|
|
|
.. module:: responder
|
|
|
|
.. autoclass:: API
|
|
:inherited-members:
|
|
|
|
|
|
Request
|
|
-------
|
|
|
|
The request object is passed into every view as the first argument. It
|
|
gives you access to everything the client sent — headers, query
|
|
parameters, the request body, cookies, and more.
|
|
|
|
Most properties are synchronous, but reading the body requires ``await``
|
|
because it involves I/O.
|
|
|
|
.. autoclass:: Request
|
|
:inherited-members:
|
|
|
|
|
|
Response
|
|
--------
|
|
|
|
The response object is passed into every view as the second argument.
|
|
Mutate it to control what gets sent back to the client — the body,
|
|
status code, headers, and cookies.
|
|
|
|
.. autoclass:: Response
|
|
:inherited-members:
|
|
|
|
|
|
Route Groups
|
|
------------
|
|
|
|
Group related routes under a shared URL prefix — useful for API versioning
|
|
and organizing large applications.
|
|
|
|
.. autoclass:: responder.api.RouteGroup
|
|
:members:
|
|
|
|
|
|
Background Queue
|
|
----------------
|
|
|
|
Run tasks in background threads without blocking the response. Available
|
|
as ``api.background``.
|
|
|
|
.. autoclass:: responder.background.BackgroundQueue
|
|
:members:
|
|
|
|
|
|
Query Dict
|
|
----------
|
|
|
|
A dictionary subclass for query string parameters with multi-value support.
|
|
|
|
.. autoclass:: responder.models.QueryDict
|
|
:members:
|
|
|
|
|
|
Rate Limiter
|
|
------------
|
|
|
|
In-memory token bucket rate limiter. Limits requests per client IP address
|
|
and returns ``429 Too Many Requests`` when exceeded.
|
|
|
|
.. autoclass:: responder.ext.ratelimit.RateLimiter
|
|
:members:
|
|
|
|
|
|
Status Code Helpers
|
|
-------------------
|
|
|
|
Convenience functions for checking which category a status code falls
|
|
into. Useful in middleware and after-request hooks.
|
|
|
|
.. autofunction:: responder.status_codes.is_100
|
|
|
|
.. autofunction:: responder.status_codes.is_200
|
|
|
|
.. autofunction:: responder.status_codes.is_300
|
|
|
|
.. autofunction:: responder.status_codes.is_400
|
|
|
|
.. autofunction:: responder.status_codes.is_500
|