StreamMessage
faststream.broker.fastapi.StreamMessage #
Bases: Request
A class to represent a stream message.
METHOD | DESCRIPTION |
---|---|
__init__ | initializes the StreamMessage object |
get_session | returns a callable function that handles the session of the message |
Initialize a class instance.
PARAMETER | DESCRIPTION |
---|---|
body | The body of the request as a dictionary. |
headers | The headers of the request as a dictionary. TYPE: |
path | The path of the request as a dictionary. TYPE: |
Source code in faststream/broker/fastapi/route.py
close async
#
form #
form(
*,
max_files: Union[int, float] = 1000,
max_fields: Union[int, float] = 1000
) -> AwaitableOrContextManager[FormData]
Source code in starlette/requests.py
get_session classmethod
#
get_session(
dependant: Dependant,
dependency_overrides_provider: Optional[Any] = None,
) -> Callable[
[StreamMessage[Any]], Awaitable[SendableMessage]
]
Creates a session for handling requests.
PARAMETER | DESCRIPTION |
---|---|
dependant | The dependant object representing the session. TYPE: |
dependency_overrides_provider | Optional provider for dependency overrides. |
RETURNS | DESCRIPTION |
---|---|
Callable[[StreamMessage[Any]], Awaitable[SendableMessage]] | A callable that takes a native message and returns an awaitable sendable message. |
RAISES | DESCRIPTION |
---|---|
AssertionError | If the dependant call is not defined. |
Note
This function is used to create a session for handling requests. It takes a dependant object, which represents the session, and a dependency overrides provider, which allows for overriding dependencies. It returns a callable that takes a native message and returns an awaitable sendable message. The session is created based on the dependant object and the message passed to the callable. The session is then used to call the function obtained from the dependant object, and the result is returned.
Source code in faststream/broker/fastapi/route.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
|
is_disconnected async
#
is_disconnected() -> bool
Source code in starlette/requests.py
send_push_promise async
#
send_push_promise(path: str) -> None
Source code in starlette/requests.py
stream async
#
stream() -> AsyncGenerator[bytes, None]