HTTPConnection 类¶
当您想要定义应同时兼容 HTTP 和 WebSocket 的依赖项时,可以定义一个接受 HTTPConnection 类型参数,而不是 Request 或 WebSocket。
您可以从 fastapi.requests 导入它:
from fastapi.requests import HTTPConnection
fastapi.requests.HTTPConnection
¶
HTTPConnection(scope, receive=None)
Bases: Mapping[str, Any]
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
77 78 79 | |
url_for
¶
url_for(name, /, **path_params)
Source code in starlette\requests.py
183 184 185 186 187 188 | |