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¶
Literal['GET', 'POST', 'DELETE', 'PATCH', 'PUT', 'HEAD', 'TRACE', 'OPTIONS'] |HttpMethod的別名
ASGI Application¶
- litestar.types.ASGIApp¶
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¶
HTTPScope|WebSocketScope的別名
- litestar.types.Receive¶
Callable[[...],Awaitable[HTTPRequestEvent|HTTPDisconnectEvent|WebSocketConnectEvent|WebSocketReceiveEvent|WebSocketDisconnectEvent]] 的別名
- litestar.types.Send¶
Callable[[HTTPResponseStartEvent|HTTPResponseBodyEvent|HTTPServerPushEvent|HTTPDisconnectEvent|WebSocketAcceptEvent|WebSocketSendEvent|WebSocketResponseStartEvent|WebSocketResponseBodyEvent|WebSocketCloseEvent],Awaitable[None]] 的別名
ASGI Scopes¶
ASGI Events¶
- class litestar.types.WebSocketResponseStartEvent[原始碼]¶
基底類別:
HeaderScopeASGI websocket.http.response.start event.
- class litestar.types.WebSocketResponseBodyEvent[原始碼]¶
基底類別:
TypedDictASGI websocket.http.response.body event.
- class litestar.types.LifeSpanStartupCompleteEvent[原始碼]¶
基底類別:
TypedDictASGI lifespan.startup.complete event.
- class litestar.types.LifeSpanStartupFailedEvent[原始碼]¶
基底類別:
TypedDictASGI lifespan.startup.failed event.
Event Groupings¶
- litestar.types.HTTPReceiveMessage¶
- litestar.types.WebSocketReceiveMessage¶
WebSocketConnectEvent|WebSocketReceiveEvent|WebSocketDisconnectEvent的別名
- litestar.types.LifeSpanReceiveMessage¶
- litestar.types.HTTPSendMessage¶
HTTPResponseStartEvent|HTTPResponseBodyEvent|HTTPServerPushEvent|HTTPDisconnectEvent的別名
- litestar.types.WebSocketSendMessage¶
WebSocketAcceptEvent|WebSocketSendEvent|WebSocketResponseStartEvent|WebSocketResponseBodyEvent|WebSocketCloseEvent的別名
- litestar.types.LifeSpanSendMessage¶
LifeSpanStartupCompleteEvent|LifeSpanStartupFailedEvent|LifeSpanShutdownCompleteEvent|LifeSpanShutdownFailedEvent的別名
- litestar.types.LifeSpanReceive¶
Callable[[...],Awaitable[LifeSpanStartupEvent|LifeSpanShutdownEvent]] 的別名
- litestar.types.LifeSpanSend¶
Callable[[LifeSpanStartupCompleteEvent|LifeSpanStartupFailedEvent|LifeSpanShutdownCompleteEvent|LifeSpanShutdownFailedEvent],Awaitable[None]] 的別名
Send / Receive Parameter Types¶
- litestar.types.Message¶
HTTPResponseStartEvent|HTTPResponseBodyEvent|HTTPServerPushEvent|HTTPDisconnectEvent|WebSocketAcceptEvent|WebSocketSendEvent|WebSocketResponseStartEvent|WebSocketResponseBodyEvent|WebSocketCloseEvent的別名
- litestar.types.ReceiveMessage¶
HTTPRequestEvent|HTTPDisconnectEvent|WebSocketConnectEvent|WebSocketReceiveEvent|WebSocketDisconnectEvent的別名
Helper Types¶
Helper types are useful generic types that can be used.
Protocols¶
- class litestar.types.Logger[原始碼]¶
基底類別:
ProtocolLogger protocol.
- exception(event: str, *args: Any, **kwargs: Any) Any[原始碼]¶
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[原始碼]¶
Set the log level
- 參數:
level¶ -- Log level to set as an integer
- 回傳:
None
- __init__(*args, **kwargs)¶
Composite Types¶
- litestar.types.Dependencies¶
Mapping[str, Union[Provide, AnyCallable]] 的別名
- litestar.types.ExceptionHandlersMap¶
MutableMapping[Union[int, type[Exception]], ExceptionHandler] 的別名
- litestar.types.ResponseCookies¶
Union[Sequence[Cookie], Mapping[str, str]] 的別名
- litestar.types.ResponseHeaders¶
Union[Sequence[ResponseHeader], Mapping[str, str]] 的別名
- litestar.types.PathType¶
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¶
Mapping[Any, Callable[[Any], Any]] 的別名
- litestar.types.TypeDecodersSequence¶
Sequence[tuple[Callable[[Any], bool], Callable[[Any, Any], Any]]] 的別名
- litestar.types.ParametersMap¶
Mapping[str, ParameterKwarg] 的別名