HTTPConnection
类¶
当你想定义同时兼容 HTTP 和 WebSockets 的依赖关系时,你可以定义一个使用 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
.
PARAMETER | DESCRIPTION |
---|---|
scope
|
TYPE:
|
receive
|
TYPE:
|
Source code in starlette/requests.py
71 72 73 |
|
url_for
¶
url_for(name, /, **path_params)
PARAMETER | DESCRIPTION |
---|---|
name
|
TYPE:
|
**path_params
|
TYPE:
|
Source code in starlette/requests.py
185 186 187 188 |
|