Skip to main content

Module webhook

Module webhook 

Source
Expand description

Fixture-safe Gingr webhook parsing and acknowledgement surfaces.

Webhooks are parsed into a quarantined envelope first. Verification is explicit, uses a caller-provided secret, and failure maps to an acknowledgement without mutating provider state or sending customer messages.

use gingr::{response, webhook};

let raw = r#"{
  "webhook_type": "animal_edited",
  "entity_id": 812,
  "entity_type": "animal",
  "entity_data": {"name": "Miso"}
}"#;
let envelope = webhook::Envelope::from_json(raw)?;
assert_eq!(envelope.event_type_input(), Some("animal_edited"));

let missing_signature = envelope.verify(&webhook::SignatureKey::from_secret("fixture-only"));
assert!(matches!(
    missing_signature,
    Err(webhook::VerificationError::MissingField { field: "signature" })
));
assert_eq!(
    webhook::Ack::RejectedPermanently.http_status(),
    response::HttpStatus::FORBIDDEN
);

Structs§

EntityId
Normalized Gingr entity identifier preserved as text across numeric and string webhook inputs.
Envelope
Raw Gingr webhook envelope before signature verification and required-field promotion.
Payload
Provider-specific webhook payload body retained for downstream DTO mapping.
SignatureKey
Secret used to validate Gingr webhook signatures before payloads can influence workflow evidence.
Verified
Webhook payload that passed signature validation and required entity/event checks.

Enums§

Ack
HTTP acknowledgement categories returned to Gingr after webhook handling.
EntityType
Gingr webhook entity classes normalized from provider strings while retaining unknown entities.
EventType
Gingr webhook event names normalized from provider strings while retaining unknown events.
ParseError
Failures while reading the raw Gingr webhook JSON envelope.
VerificationError
Reasons a Gingr webhook cannot be trusted or promoted.

Type Aliases§

ParseResult
Shared result for reading raw webhook JSON before signature verification.
VerificationResult
Shared result for signature checks that decide whether a webhook may influence downstream workflows.