pub struct WebhookTrigger {
pub path: String,
pub secret: Option<String>,
pub required_fields: HashMap<String, String>,
pub description: String,
}Expand description
Configuration for an HTTP POST webhook trigger.
When an HTTP POST arrives at path, the JSON body is decoded and checked:
- If
secretis set, theX-Hub-Signature-256header must contain a valid HMAC-SHA256 signature of the raw body (pure-Rust implementation). - All entries in
required_fieldsmust be present in the JSON object with the expected string values.
Real HTTP integration is the caller’s responsibility; see WebhookRouter.
Fields§
§path: StringURL path that activates this trigger (e.g. "/webhooks/ingest-ready").
secret: Option<String>Optional HMAC-SHA256 secret for signature verification.
required_fields: HashMap<String, String>JSON body fields that must match to fire the trigger.
description: StringOptional description.
Implementations§
Source§impl WebhookTrigger
impl WebhookTrigger
Sourcepub fn with_secret(self, secret: impl Into<String>) -> Self
pub fn with_secret(self, secret: impl Into<String>) -> Self
Set an HMAC-SHA256 secret for signature verification.
Sourcepub fn with_required_field(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_required_field( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Require a JSON body field to have a specific value.
Sourcepub fn with_description(self, desc: impl Into<String>) -> Self
pub fn with_description(self, desc: impl Into<String>) -> Self
Set a human-readable description.
Sourcepub fn verify_signature(&self, payload: &[u8], signature: &str) -> bool
pub fn verify_signature(&self, payload: &[u8], signature: &str) -> bool
Verify the HMAC-SHA256 signature of a raw payload.
signature is the hex-encoded digest (e.g. the value of the
X-Hub-Signature-256 header without any sha256= prefix).
Returns true when the signature is valid or no secret is configured.
Sourcepub fn body_matches(&self, body: &Value) -> bool
pub fn body_matches(&self, body: &Value) -> bool
Check whether a parsed JSON body satisfies the required-fields filter.
Trait Implementations§
Source§impl Clone for WebhookTrigger
impl Clone for WebhookTrigger
Source§fn clone(&self) -> WebhookTrigger
fn clone(&self) -> WebhookTrigger
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more