Skip to main content

Module webhook

Module webhook 

Source
Expand description

Webhook handling with signature verification.

Forge provides a structured way to receive webhooks from external services with automatic signature verification and idempotency handling.

§Signature Verification

Webhooks can verify signatures using HMAC-SHA256 or other algorithms:

#[forge::webhook(
    path = "/webhooks/stripe",
    signature = "hmac_sha256",
    secret_env = "STRIPE_WEBHOOK_SECRET"
)]
async fn handle_stripe(ctx: &WebhookContext, payload: StripeEvent) -> WebhookResult {
    // Signature already verified
}

§Idempotency

Webhooks can be configured to deduplicate based on a header or payload field:

#[forge::webhook(
    path = "/webhooks/github",
    idempotency_key = "header:X-GitHub-Delivery"
)]

§Key Types

Structs§

IdempotencyConfig
Configuration for webhook idempotency.
SignatureConfig
Configuration for webhook signature validation.
WebhookContext
Context available to webhook handlers.
WebhookInfo
Webhook metadata.
WebhookSignature
Helper for constructing signature configurations.

Enums§

IdempotencySource
Source for extracting idempotency key.
SignatureAlgorithm
Supported signature algorithms.
WebhookResult
Result returned by webhook handlers.

Traits§

ForgeWebhook
Trait for FORGE webhook handlers.