get_request_handler
No overview available.
def get_request_handler(
dependant: Dependant,
body_field: ModelField | None = None,
status_code: int | None = None,
response_class: type[Response] | DefaultPlaceholder = Default(JSONResponse),
response_field: ModelField | None = None,
response_model_include: IncEx | None = None,
response_model_exclude: IncEx | None = None,
response_model_by_alias: bool = True,
response_model_exclude_unset: bool = False,
response_model_exclude_defaults: bool = False,
response_model_exclude_none: bool = False,
dependency_overrides_provider: Any | None = None,
embed_body_fields: bool = False,
strict_content_type: bool | DefaultPlaceholder = Default(True),
stream_item_field: ModelField | None = None,
is_json_stream: bool = False
) - > Callable[[Request], Coroutine[Any, Any, Response]]
Creates and returns an asynchronous request handler function for a given API endpoint. This handler manages the entire request-response lifecycle, including body parsing, dependency resolution, endpoint execution, and response serialization, supporting various response types like JSON, Server-Sent Events (SSE), and JSON Lines (JSONL).
Parameters
| Name | Type | Description |
|---|---|---|
| dependant | Dependant | The Dependant object containing information about the endpoint's callable, its dependencies, and other metadata. |
| body_field | `ModelField | None` = None |
| status_code | `int | None` = None |
| response_class | `type[Response] | DefaultPlaceholder` = Default(JSONResponse) |
| response_field | `ModelField | None` = None |
| response_model_include | `IncEx | None` = None |
| response_model_exclude | `IncEx | None` = None |
| response_model_by_alias | bool = True | A boolean indicating whether to serialize the response model using field aliases. |
| response_model_exclude_unset | bool = False | A boolean indicating whether to exclude fields that were not explicitly set in the response model. |
| response_model_exclude_defaults | bool = False | A boolean indicating whether to exclude fields that have their default values in the response model. |
| response_model_exclude_none | bool = False | A boolean indicating whether to exclude fields that have a value of None in the response model. |
| dependency_overrides_provider | `Any | None` = None |
| embed_body_fields | bool = False | A boolean indicating whether to embed body fields directly into the request parameters. |
| strict_content_type | `bool | DefaultPlaceholder` = Default(True) |
| stream_item_field | `ModelField | None` = None |
| is_json_stream | bool = False | A boolean indicating whether the response should be streamed as JSON Lines (JSONL). |
Returns
| Type | Description |
|---|---|
Callable[[Request], Coroutine[Any, Any, Response]] | An asynchronous callable that takes a Request object and returns a Response object, representing the complete request handling logic for the endpoint. |