# `Codat.Webhooks.Dispatcher`
[🔗](https://github.com/iamkanishka/codat.git/blob/v1.0.0/lib/codat/webhooks/dispatcher.ex#L1)

Routes Codat webhook events to multiple handlers based on event type patterns.

## Example

    defmodule MyApp.CodatWebhooks do
      use Codat.Webhooks.Dispatcher

      on ["invoices.write.successful", "invoices.write.unsuccessful"],
         to: MyApp.InvoiceSyncHandler

      on ~r/^billPayments\.write\./,
         to: MyApp.BillingHandler

      on :all, to: MyApp.AuditLogHandler
    end

Use as the `:handler` in `Codat.Webhooks.Plug`:

    forward "/webhooks/codat", Codat.Webhooks.Plug,
      secret: "whsec_...",
      handler: MyApp.CodatWebhooks

# `on`
*macro* 

Registers a route mapping event type(s) to a handler module.

- String — exact match
- List — match any element
- Regex — pattern match
- `:all` — catch-all fallback

---

*Consult [api-reference.md](api-reference.md) for complete listing*
