pub struct WebhookNotifier { /* private fields */ }Expand description
Builds outbound webhook payloads and signatures.
The notifier is stateless with respect to HTTP transport — it only builds
the JSON body and HMAC-SHA256 signature. Callers are responsible for
actually sending the HTTP POST (e.g. using reqwest or hyper).
Implementations§
Source§impl WebhookNotifier
impl WebhookNotifier
Sourcepub fn new(config: WebhookConfig) -> Self
pub fn new(config: WebhookConfig) -> Self
Create a new notifier with the given configuration.
Sourcepub fn config(&self) -> &WebhookConfig
pub fn config(&self) -> &WebhookConfig
Returns a reference to the underlying configuration.
Sourcepub fn build_payload(
&self,
event: &WebhookEvent,
context: &WorkflowContext,
) -> String
pub fn build_payload( &self, event: &WebhookEvent, context: &WorkflowContext, ) -> String
Build the JSON payload string for the given event and context.
The payload is a JSON object with the following fields:
event_type: dot-separated event name (seeWebhookEvent::event_type)workflow_id: fromcontext.workflow_idworkflow_name: fromcontext.workflow_namestate: fromcontext.statetimestamp_ms: Unix epoch in millisecondsvariables: fromcontext.variablesstep_name(optional): only present for step-level events
Sourcepub fn compute_signature(&self, payload: &str) -> Option<String>
pub fn compute_signature(&self, payload: &str) -> Option<String>
Compute HMAC-SHA256 of payload using the configured secret.
Returns None when no secret is configured, or Some(hex_string) (64
lowercase hex characters) when a secret is set.
Sourcepub fn should_notify(&self, event: &WebhookEvent) -> bool
pub fn should_notify(&self, event: &WebhookEvent) -> bool
Returns true when the notifier is configured to send a notification for
the given event.
Matching is done by event type string so that, for example, any
StepCompleted { .. } event matches a StepCompleted { step_name: _ } entry.
Trait Implementations§
Source§impl Clone for WebhookNotifier
impl Clone for WebhookNotifier
Source§fn clone(&self) -> WebhookNotifier
fn clone(&self) -> WebhookNotifier
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more