SkillKit.Webhook.Plug (SkillKit v0.1.0)

Copy Markdown View Source

Plug that routes inbound webhook requests.

Mounted by the host (typically via Phoenix forward) at the base path configured as the public URL root:

forward "/webhooks", to: SkillKit.Webhook.Plug

The path after the forward prefix is interpreted as the webhook id. A single request passes through resolve/3: look up the webhook record, the running agent, verify the signature, check idempotency. Depending on the outcome the Plug responds with one of 200 / 202 / 401 / 404 / 500 / 503. The handshake short-circuit (Slack url_verification) is returned as-is — the verifier wrote the response itself.

On success the Plug hands the delivery to the configured SkillKit.Webhook.Inbox impl via Inbox.put/2. The Inbox owns persistence, retention, and dispatch timing; it calls SkillKit.send_event/3 on the bound agent when it decides to emit. The Plug returns 202 as soon as put/2 returns :ok.