request
Request §
Request(context, scope, receive, path, background_chan, response_chan)
The Tokamak request class for sending responses and scheduling background tasks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context |
Dict[str, str]
|
Context from the matching path |
required |
scope |
dict
|
Request scope dictionary |
required |
receive |
Channel
|
Channel for receiving the request body |
required |
path |
str
|
Path matched for this request |
required |
background_chan |
trio._channel.MemorySendChannel
|
Send channel for scheduling background tasks |
required |
response_chan |
trio._channel.MemorySendChannel
|
Send channel for submitting a response |
required |
register_background
async
§
register_background(callable)
Method to schedule background tasks in a request handler
Parameters:
Name | Type | Description | Default |
---|---|---|---|
callable |
Callable
|
Arbitrary async function |
required |
respond_with
async
§
respond_with(response)
In order to send a response to a client this method must be called.
This allows the Tokamak framework to properly handle cancellations and time-limits around request-handling.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
response |
Response
|
Response class to send to client. |
required |