Skip to main content

Module adapter

Module adapter 

Source
Available on crate feature rest only.
Expand description

What every Adapter does with a request, whatever the platform: verify the signature, parse, dispatch to the InteractionHandler (or hand a Webhook Event to the EventHandler as Background Work), and send responses with files through the callback endpoint. Adapters map the outcomes to their platform’s HTTP response, so every Adapter answers alike.

Enums§

EventOutcome
What to answer one Webhook Events request with. Produced by handle_event.
FilesError
Why send_with_files could not send the response
InteractionOutcome
What to answer one interaction request with. Produced by handle_interaction.

Constants§

DEFAULT_EVENTS_PATH
Path Webhook Events are served on unless the Adapter is told otherwise; every other path serves Interactions
SIGNATURE_HEADER
Header carrying the request’s Ed25519 signature (hex)
TIMESTAMP_HEADER
Header carrying the timestamp the signature covers

Functions§

handle_event
Verifies and parses one Webhook Events request and spawns its handling as Background Work, without any platform. Adapters call handle_event_with_key for the events path; call this directly to test an EventHandler with signed payloads.
handle_event_with_key
handle_event with a parsed PublicKey, as Adapters call it
handle_interaction
Verifies, parses, and dispatches one interaction request without any platform. Adapters call handle_interaction_with_key; call this directly to test a handler with signed payloads.
handle_interaction_with_key
handle_interaction with a parsed PublicKey, as Adapters call it
outlined
Awaits future with its poll in a function of its own, which the optimizer cannot merge into the caller’s.
send_with_files
Sends a response carrying files (multipart, which an HTTP reply cannot be) through the callback endpoint; the Adapter then answers the request with an empty 202. body is the interaction request body: the ids and token are read from it again, so the common path keeps no copy.
verify
Whether both signature headers are present and sign body with public_key