Inngest.Router.Phoenix (Inngest v0.3.0)

Copy Markdown View Source

Router module expected to be used with a Phoenix router.

Examples

defmodule MyAppWeb.Router do
  use MyAppWeb, :router
  use Inngest.Router, :phoenix

  scope "/" do
    pipe_through(:api)

    inngest("/api/inngest", client: MyApp.Inngest)
  end
end

Inngest verifies inbound request signatures against the raw request body. In Phoenix applications, configure Plug.Parsers with Inngest.CacheBodyReader in your endpoint so the router can verify signed requests:

plug Plug.Parsers,
  parsers: [:urlencoded, :json],
  pass: ["*/*"],
  body_reader: {Inngest.CacheBodyReader, :read_body, [[paths: ["/api/inngest"]]]},
  json_decoder: Phoenix.json_library()

plug MyAppWeb.Router

Plug's multipart parser does not use the :body_reader option. Inngest signed requests are JSON, so the :json parser is the important one for signature verification.

Summary

Functions

inngest(path, opts)

(macro)