channel
Channels and messages for sending auxiliary content (such as scripts, styles, and audio) to the client alongside a response's main body.
DEFAULT_CHANNELS = [DEFAULT_CHANNEL_AUDIO, DEFAULT_CHANNEL_BEFORE, DEFAULT_CHANNEL_AFTER]
module-attribute
The channel names that Drafter itself uses when building responses.
DEFAULT_CHANNEL_AFTER = 'after'
module-attribute
Channel whose messages are injected after the page content is rendered.
DEFAULT_CHANNEL_AUDIO = 'audio'
module-attribute
Channel carrying audio content for the client to play.
DEFAULT_CHANNEL_BEFORE = 'before'
module-attribute
Channel whose messages are injected before the page content is rendered.
Channel(name, messages=list())
dataclass
Represents a communication channel for additional content.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The name of the channel. |
messages |
list[Message]
|
The messages to be sent through the channel. |
Message(channel_name, kind, sigil, content)
dataclass
Represents a message to be sent through a channel.
Attributes:
| Name | Type | Description |
|---|---|---|
channel_name |
str
|
The name of the channel through which the message will be sent. |
content |
str
|
The content of the message. |
kind |
str
|
The kind of message (e.g., "script", "style"). |
sigil |
str | None
|
An optional sigil for special processing. A sigil is a marker that indicates whether the message has been seen or processed before; it can be used to avoid duplicate injections of the same content. |