types¶
Callable types¶
- litestar.types.AfterExceptionHookHandler = 'Callable[[ExceptionT, Scope], SyncOrAsyncUnion[None]]'¶
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
- litestar.types.AfterRequestHookHandler = 'AsyncAfterRequestHookHandler | SyncAfterRequestHookHandler'¶
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
- litestar.types.AfterResponseHookHandler = 'AsyncAfterResponseHookHandler | SyncAfterResponseHookHandler'¶
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
- litestar.types.BeforeMessageSendHookHandler = 'Callable[[Message, Scope], SyncOrAsyncUnion[None]]'¶
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
- litestar.types.BeforeRequestHookHandler = 'Callable[[Request], Any | Awaitable[Any]]'¶
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
- litestar.types.CacheKeyBuilder = 'Callable[[Request], str]'¶
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
- litestar.types.ExceptionHandler = 'Callable[[Request, ExceptionT], Response]'¶
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
- litestar.types.Guard = 'AsyncGuard | SyncGuard'¶
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
- litestar.types.LifespanHook = 'Callable[[Litestar], SyncOrAsyncUnion[Any]] | Callable[[], SyncOrAsyncUnion[Any]]'¶
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
- litestar.types.OnAppInitHandler = 'Callable[[AppConfig], AppConfig]'¶
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
ASGI Types¶
- litestar.types.Method¶
alias of
Literal[‘GET’, ‘POST’, ‘DELETE’, ‘PATCH’, ‘PUT’, ‘HEAD’, ‘TRACE’, ‘OPTIONS’] |HttpMethod
ASGI Application¶
- litestar.types.ASGIApp¶
alias of
Callable[[HTTPScope|WebSocketScope,Callable[[…],Awaitable[HTTPRequestEvent|HTTPDisconnectEvent|WebSocketConnectEvent|WebSocketReceiveEvent|WebSocketDisconnectEvent]],Callable[[HTTPResponseStartEvent|HTTPResponseBodyEvent|HTTPServerPushEvent|HTTPDisconnectEvent|WebSocketAcceptEvent|WebSocketSendEvent|WebSocketResponseStartEvent|WebSocketResponseBodyEvent|WebSocketCloseEvent],Awaitable[None]]],Awaitable[None]]
ASGI Application Parameters¶
- litestar.types.Scope¶
alias of
HTTPScope|WebSocketScope
- litestar.types.Receive¶
alias of
Callable[[…],Awaitable[HTTPRequestEvent|HTTPDisconnectEvent|WebSocketConnectEvent|WebSocketReceiveEvent|WebSocketDisconnectEvent]]
- litestar.types.Send¶
alias of
Callable[[HTTPResponseStartEvent|HTTPResponseBodyEvent|HTTPServerPushEvent|HTTPDisconnectEvent|WebSocketAcceptEvent|WebSocketSendEvent|WebSocketResponseStartEvent|WebSocketResponseBodyEvent|WebSocketCloseEvent],Awaitable[None]]
ASGI Scopes¶
ASGI Events¶
- class litestar.types.HTTPResponseStartEvent[source]¶
Bases:
HeaderScopeASGI http.response.start event.
- class litestar.types.WebSocketResponseStartEvent[source]¶
Bases:
HeaderScopeASGI websocket.http.response.start event.
- class litestar.types.WebSocketResponseBodyEvent[source]¶
Bases:
TypedDictASGI websocket.http.response.body event.
- class litestar.types.WebSocketDisconnectEvent[source]¶
Bases:
TypedDictASGI websocket.disconnect event.
- class litestar.types.LifeSpanStartupCompleteEvent[source]¶
Bases:
TypedDictASGI lifespan.startup.complete event.
- class litestar.types.LifeSpanStartupFailedEvent[source]¶
Bases:
TypedDictASGI lifespan.startup.failed event.
Event Groupings¶
- litestar.types.HTTPReceiveMessage¶
alias of
HTTPRequestEvent|HTTPDisconnectEvent
- litestar.types.WebSocketReceiveMessage¶
alias of
WebSocketConnectEvent|WebSocketReceiveEvent|WebSocketDisconnectEvent
- litestar.types.LifeSpanReceiveMessage¶
alias of
LifeSpanStartupEvent|LifeSpanShutdownEvent
- litestar.types.HTTPSendMessage¶
alias of
HTTPResponseStartEvent|HTTPResponseBodyEvent|HTTPServerPushEvent|HTTPDisconnectEvent
- litestar.types.WebSocketSendMessage¶
alias of
WebSocketAcceptEvent|WebSocketSendEvent|WebSocketResponseStartEvent|WebSocketResponseBodyEvent|WebSocketCloseEvent
- litestar.types.LifeSpanSendMessage¶
alias of
LifeSpanStartupCompleteEvent|LifeSpanStartupFailedEvent|LifeSpanShutdownCompleteEvent|LifeSpanShutdownFailedEvent
- litestar.types.LifeSpanReceive¶
alias of
Callable[[…],Awaitable[LifeSpanStartupEvent|LifeSpanShutdownEvent]]
- litestar.types.LifeSpanSend¶
alias of
Callable[[LifeSpanStartupCompleteEvent|LifeSpanStartupFailedEvent|LifeSpanShutdownCompleteEvent|LifeSpanShutdownFailedEvent],Awaitable[None]]
Send / Receive Parameter Types¶
- litestar.types.Message¶
alias of
HTTPResponseStartEvent|HTTPResponseBodyEvent|HTTPServerPushEvent|HTTPDisconnectEvent|WebSocketAcceptEvent|WebSocketSendEvent|WebSocketResponseStartEvent|WebSocketResponseBodyEvent|WebSocketCloseEvent
- litestar.types.ReceiveMessage¶
alias of
HTTPRequestEvent|HTTPDisconnectEvent|WebSocketConnectEvent|WebSocketReceiveEvent|WebSocketDisconnectEvent
Helper Types¶
Helper types are useful generic types that can be used.
Protocols¶
- class litestar.types.Logger[source]¶
Bases:
ProtocolLogger protocol.
- warning(event: str, *args: Any, **kwargs: Any) Any[source]¶
Output a log message at ‘WARNING’ level.
- exception(event: str, *args: Any, **kwargs: Any) Any[source]¶
Log a message with level ‘ERROR’ on this logger. The arguments are interpreted as for debug(). Exception info is added to the logging message.
- setLevel(level: int) None[source]¶
Set the log level
- Parameters:
level¶ – Log level to set as an integer
- Returns:
None
- __init__(*args, **kwargs)¶
Composite Types¶
- litestar.types.Dependencies¶
alias of Mapping[str, Union[Provide, AnyCallable]]
- litestar.types.ExceptionHandlersMap¶
alias of MutableMapping[Union[int, type[Exception]], ExceptionHandler]
- litestar.types.ResponseCookies¶
alias of Union[Sequence[Cookie], Mapping[str, str]]
- litestar.types.ResponseHeaders¶
alias of Union[Sequence[ResponseHeader], Mapping[str, str]]
- litestar.types.PathType¶
alias of Union[Path, PathLike, str]
- litestar.types.Scopes = 'set[Literal[ScopeType.HTTP, ScopeType.WEBSOCKET]]'¶
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
- litestar.types.TypeEncodersMap¶
alias of Mapping[Any, Callable[[Any], Any]]
- litestar.types.TypeDecodersSequence¶
alias of Sequence[tuple[Callable[[Any], bool], Callable[[Any, Any], Any]]]
- litestar.types.ParametersMap¶
alias of Mapping[str, ParameterKwarg]