HTTPConnection class¶
When you want to define dependencies that should be compatible with both HTTP and WebSockets, you can define a parameter that takes an HTTPConnection instead of a Request or a WebSocket.
You can import it from fastapi.requests:
from fastapi.requests import HTTPConnection
fastapi.requests.HTTPConnection
¶
HTTPConnection(scope, receive=None)
Bases: Mapping[str, Any], Generic[StateT]
A base class for incoming HTTP connections, that is used to provide
any functionality that is common to both Request and WebSocket.
Source code in starlette/requests.py
85 86 87 | |
url_for
¶
url_for(name, /, **path_params)
Source code in starlette/requests.py
192 193 194 195 196 197 | |