Expand description
Fixture-safe Gingr webhook parsing and acknowledgement contracts.
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§
- Entity
Id - 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.
- Signature
Key - Secret used to validate Gingr webhook signatures before payloads cross the provider boundary.
- Verified
- Webhook payload that passed signature validation and required entity/event checks.
Enums§
- Ack
- HTTP acknowledgement categories returned to Gingr after webhook handling.
- Entity
Type - Gingr webhook entity classes normalized from provider strings while retaining unknown entities.
- Event
Type - Gingr webhook event names normalized from provider strings while retaining unknown events.
- Parse
Error - Failures while reading the raw Gingr webhook JSON envelope.
- Verification
Error - Reasons a Gingr webhook cannot be trusted or promoted.
Type Aliases§
- Parse
Result - Shared parse result type used across the webhook boundary.
- Verification
Result - Shared verification result type used across the webhook boundary.