ExDaytona.Webhooks.Handler behaviour (ex_daytona v0.4.0)

Copy Markdown View Source

Behaviour for ExDaytona.Webhooks.Plug event handlers.

defmodule MyApp.DaytonaWebhooks do
  @behaviour ExDaytona.Webhooks.Handler

  @impl true
  def handle_event(%{"type" => "sandbox.state.updated"} = event, _conn) do
    MyApp.Sandboxes.sync(event["data"])
  end

  def handle_event(_event, _conn), do: :ok
end

Return :ok (or {:ok, term}) to acknowledge the delivery with a 204; return {:error, term} (or raise) to answer 500 so the provider retries it later.

Summary

Callbacks

handle_event(event, conn)

@callback handle_event(event :: map() | list() | binary(), conn :: Plug.Conn.t()) ::
  :ok | {:ok, term()} | {:error, term()}