HTTP Providers¶
HTTPProvider ¶
Bases: ABC
Generic HTTP webhook delivery provider.
send
abstractmethod
async
¶
Send an event via HTTP webhook.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
RoomEvent
|
The room event to deliver. |
required |
to
|
str
|
Target webhook URL. |
required |
Returns:
| Type | Description |
|---|---|
ProviderResult
|
Result with provider-specific delivery metadata. |
MockHTTPProvider ¶
WebhookHTTPProvider ¶
Bases: HTTPProvider
HTTP provider that POSTs JSON payloads to a webhook URL.
transport is handed to the provider's httpx.AsyncClient as it is.
The config validates webhook_url once, when it is built, and the client
resolves the name again at every send; a caller whose outbound policy must
judge the address actually dialled (pin-on-connect, see
:mod:roomkit.providers.url_safety) puts that policy here, and a test puts
a MockTransport here instead of behind the network. None leaves
httpx to build its default transport.
A subclass shapes what is sent by overriding :meth:build_payload (the
JSON body: a Slack or Teams rendering, say) and :meth:build_headers (a
signature scheme of its own), and reads its settings through
:attr:config.
build_payload ¶
The JSON body sent for event to to, text its extracted text.
RoomKit's envelope by default: recipient, channel, room, the text as content, and the event's metadata. Override it to send another shape.
build_headers ¶
The request headers for body, the serialized payload.
Content-Type, the configured headers, and an
X-RoomKit-Signature (HMAC-SHA256 of body) when a secret is set.
Override it to sign another way.