patera.controller¶
Controllers and endpoint decorators. See the controllers guide.
Controller subpackage
Controller
¶
Controller(app: AppT, url_path: str = '/', open_api_spec: bool = True, open_api_tags: Optional[list[str]] = None, alias: Optional[str] = None)
Descriptor
¶
Descriptor(status: int | HttpStatus = BAD_REQUEST, description: Optional[str] = None, media_type: MediaType = APPLICATION_JSON, body: Optional[Type[BaseModel]] = None)
path
¶
path(url_path: str = '/', open_api_spec: bool = True, tags: Optional[list[str]] = None, alias: Optional[str] = None) -> 'Callable'
get
¶
get(url_path: str, open_api_spec: bool = True, tags: Optional[list[str]] = None) -> _EndpointDecorator
GET http handler decorator.
consumes
¶
consumes(media_type: MediaType) -> _EndpointDecorator
Decorator indicating what media type the endpoint consumes.
produces
¶
produces(media_type: MediaType, status_code: HttpStatus = OK) -> _EndpointDecorator
Decorator indicating what media type the endpoint produces and what the default status code is.
Important: - this acts as metadata and default behavior - it does not override an explicit response media type or explicit content-type header
open_api_docs
¶
open_api_docs(*args: Descriptor)
Adds descriptions for error responses to OpenAPI documentation
cors
¶
no_cors
¶
max_content_length
¶
Sets the largest request body, in bytes, one endpoint accepts. It overrides the MAX_CONTENT_LENGTH setting for that endpoint; None removes the limit. Larger bodies are answered with 413.
Usage: