ExLine.Webhook.Plug (ExLine v0.1.0)

Copy Markdown View Source

Plug that verifies the LINE webhook signature and halts with 401 on failure.

The channel secret is supplied via the :secret option, which is the key to multi-channel support: pass either a static binary, or a 1-arity function that resolves the secret from the conn at request time (e.g. by the product in the path). The SDK never holds a channel registry.

# static secret
plug ExLine.Webhook.Plug, secret: System.fetch_env!("LINE_CHANNEL_SECRET")

# resolver — pick the secret per request
plug ExLine.Webhook.Plug, secret: &MyApp.line_secret/1

Requires the raw body to be cached by ExLine.Webhook.BodyReader.

Ref: https://developers.line.biz/en/docs/messaging-api/receiving-messages/#verifying-signatures