Inertia Request¶
- class litestar_vite.inertia.request.InertiaDetails[source]¶
Bases:
object
InertiaDetails holds all the values sent by Inertia client in headers and provide convenient properties.
- __init__(request: Request[UserT, AuthT, StateT]) None [source]¶
Initialize
InertiaDetails
- class litestar_vite.inertia.request.InertiaRequest[source]¶
Bases:
Request
[UserT
,AuthT
,StateT
]Inertia Request class to work with Inertia client.
- __init__(scope: Scope, receive: Receive = <function empty_receive>, send: Send = <function empty_send>) None [source]¶
Initialize
InertiaRequest
- property inertia_enabled: bool¶
True if the route handler contains an inertia enabled configuration.
- property is_partial_render: bool¶
True if the route handler contains an inertia enabled configuration.
- property partial_keys: set[str]¶
True if the route handler contains an inertia enabled configuration.
- property accept: Accept¶
Parse the request’s ‘Accept’ header, returning an
Accept
instance.- Returns:
An
Accept
instance, representing the list of acceptable media types.
- property app: Litestar¶
Return the
app
for this connection.- Returns:
The
Litestar
application instance
- property auth: AuthT¶
Return the
auth
data of this connection’sScope
.- Raises:
ImproperlyConfiguredException – If
auth
is not set in scope via anAuthMiddleware
, raises an exception- Returns:
A type correlating to the generic variable Auth.
- property base_url: URL¶
Return the base URL of this connection’s
Scope
.- Returns:
A URL instance constructed from the request’s scope, representing only the base part (host + domain + prefix) of the request.
- async body() bytes ¶
Return the body of the request.
- Returns:
A byte-string representing the body of the request.
- clear_session() None ¶
Remove the session from the connection’s
Scope
.If the
Litestar SessionMiddleware
is enabled, this will cause the session data to be cleared.- Returns:
None.
- property client: Address | None¶
Return the
client
data of this connection’sScope
.- Returns:
A two tuple of the host name and port number.
- property content_type: tuple[str, dict[str, str]]¶
Parse the request’s ‘Content-Type’ header, returning the header value and any options as a dictionary.
- Returns:
A tuple with the parsed value and a dictionary containing any options send in it.
- property cookies: dict[str, str]¶
Return the
cookies
of this connection’sScope
.- Returns:
Returns any cookies stored in the header as a parsed dictionary.
- async form() FormMultiDict ¶
Retrieve form data from the request. If the request is either a ‘multipart/form-data’ or an ‘application/x-www-form- urlencoded’, return a FormMultiDict instance populated with the values sent in the request, otherwise, an empty instance.
- Returns:
A FormMultiDict instance
- property headers: Headers¶
Return the headers of this connection’s
Scope
.- Returns:
A Headers instance with the request’s scope[“headers”] value.
- property logger: Logger¶
Return the
Logger
instance for this connection.- Returns:
A
Logger
instance.- Raises:
ImproperlyConfiguredException – if
log_config
has not been passed to the Litestar constructor.
- property method: Method¶
Return the request method.
- Returns:
The request
Method
- async msgpack() Any ¶
Retrieve the MessagePack request body from the request.
- Returns:
An arbitrary value
- property path_params: dict[str, Any]¶
Return the
path_params
of this connection’sScope
.- Returns:
A string keyed dictionary of path parameter values.
- property query_params: MultiDict[Any]¶
Return the query parameters of this connection’s
Scope
.- Returns:
A normalized dict of query parameters. Multiple values for the same key are returned as a list.
- receive: Receive¶
The ASGI receive function.
- property route_handler: HandlerT¶
Return the
route_handler
for this connection.- Returns:
The target route handler instance.
- scope: HTTPScope¶
The ASGI scope attached to the connection.
- send: Send¶
The ASGI send function.
- async send_push_promise(path: str, raise_if_unavailable: bool = False) None ¶
Send a push promise.
This method requires the http.response.push extension to be sent from the ASGI server.
- Parameters:
path – Path to send the promise to.
raise_if_unavailable – Raise an exception if server push is not supported by the server
- Returns:
None
- property session: dict[str, Any]¶
Return the session for this connection if a session was previously set in the
Scope
- Returns:
A dictionary representing the session value - if existing.
- Raises:
ImproperlyConfiguredException – if session is not set in scope.
- set_session(value: dict[str, Any] | DataContainerType | EmptyType) None ¶
Set the session in the connection’s
Scope
.If the
SessionMiddleware
is enabled, the session will be added to the response as a cookie header.- Parameters:
value – Dictionary or pydantic model instance for the session data.
- Returns:
None
- property state: StateT¶
Return the
State
of this connection.- Returns:
A State instance constructed from the scope[“state”] value.
- async stream() AsyncGenerator[bytes, None] ¶
Return an async generator that streams chunks of bytes.
- Returns:
An async generator.
- Raises:
RuntimeError – if the stream is already consumed
- property url: URL¶
Return the URL of this connection’s
Scope
.- Returns:
A URL instance constructed from the request’s scope.
- url_for(name: str, **path_parameters: Any) str ¶
Return the url for a given route handler name.
- Parameters:
name – The
name
of the request route handler.**path_parameters – Values for path parameters in the route
- Raises:
NoRouteMatchFoundException – If route with
name
does not exist, path parameters are missing or have a wrong type.- Returns:
A string representing the absolute url of the route handler.
- url_for_static_asset(name: str, file_path: str) str ¶
Receives a static files handler name, an asset file path and returns resolved absolute url to the asset.
- Parameters:
name – A static handler unique name.
file_path – a string containing path to an asset.
- Raises:
NoRouteMatchFoundException – If static files handler with
name
does not exist.- Returns:
A string representing absolute url to the asset.
- property user: UserT¶
Return the
user
data of this connection’sScope
.- Raises:
ImproperlyConfiguredException – If
user
is not set in scope via anAuthMiddleware
, raises an exception- Returns:
A type correlating to the generic variable User.