Skip to main content

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

NameTypeDescription
dependantDependantThe Dependant object containing information about the endpoint's callable, its dependencies, and other metadata.
body_field`ModelFieldNone` = None
status_code`intNone` = None
response_class`type[Response]DefaultPlaceholder` = Default(JSONResponse)
response_field`ModelFieldNone` = None
response_model_include`IncExNone` = None
response_model_exclude`IncExNone` = None
response_model_by_aliasbool = TrueA boolean indicating whether to serialize the response model using field aliases.
response_model_exclude_unsetbool = FalseA boolean indicating whether to exclude fields that were not explicitly set in the response model.
response_model_exclude_defaultsbool = FalseA boolean indicating whether to exclude fields that have their default values in the response model.
response_model_exclude_nonebool = FalseA boolean indicating whether to exclude fields that have a value of None in the response model.
dependency_overrides_provider`AnyNone` = None
embed_body_fieldsbool = FalseA boolean indicating whether to embed body fields directly into the request parameters.
strict_content_type`boolDefaultPlaceholder` = Default(True)
stream_item_field`ModelFieldNone` = None
is_json_streambool = FalseA boolean indicating whether the response should be streamed as JSON Lines (JSONL).

Returns

TypeDescription
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.