GitHub

HttpApiRequest

API reference for HttpApiRequest.

What a handler gets: the decoded params, query, payload and headers (None for a part the endpoint does not declare), the request, its endpoint and group.

Attributes

AttributeTypeDescription
paramsP_co
queryQ_co
payloadB_co
headersH_co
requestServerRequest
endpointAnyEndpoint
groupAnyGroup
upgraderCallable[[object], Effect[SocketService]] | None = field(default=None, repr=False)

Functions

__init__

__init__(params, query, payload, headers, request, endpoint, group, upgrader=None) -> None
ParameterTypeDescription
paramsP_co
queryQ_co
payloadB_co
headersH_co
requestServerRequest
endpointAnyEndpoint
groupAnyGroup
upgraderCallable[[object], Effect[SocketService]] | None = None

upgrade

upgrade(headers=None) -> Effect[SocketService]

The upgraded connection of an Upgrade endpoint, answering the 101 with headers (encoded by the upgrade's headers schema), sent once its reader is taken. Beside other successes, a handler that upgrades returns nothing.

ParameterTypeDescription
headersobject = None

Returns Effect[SocketService]

def upgrade(self, headers: object = None) -> Effect[SocketService]:
    """The upgraded connection of an ``Upgrade`` endpoint, answering the
    ``101`` with ``headers`` (encoded by the upgrade's headers schema),
    sent once its reader is taken. Beside other successes, a handler that
    upgrades returns nothing."""
    if self.upgrader is None:
        raise TypeError(f"Endpoint {self.endpoint.identifier!r} declares no Upgrade")
    return self.upgrader(headers)