Skip to content

v0.2.0

Compare
Choose a tag to compare
@danschultzer danschultzer released this 12 Apr 18:16
· 23 commits to main since this release

This is a breaking release.

If you have been using the Idempotency.Handler behaviour, change your plug to this:

plug IdempotencyPlug,
  tracker: MyAppWeb.RequestTracker,
  idempotency_key: {MyAppWeb.IdempotencyPlugHandler, :scope_idempotency_key},
  with: {MyAppWeb.IdempotencyPlugHandler, :handle_error}

And change your handler module to this:

defmodule MyAppWeb.IdempotencyPlugHandler do
  import Phoenix.Controller
  import Plug.Conn

  def scope_idempotency_key(conn, key), do: {conn.assigns.current_user.id, key}

  def handle_error(conn, error) do
    conn
    |> put_status(Plug.Exception.status(error))
    |> json(%{error: error.message})
    |> halt()
  end
end

Changes

  • IdempotencyPlug.Handler removed #2
  • IdempotencyPlug raises errors by default #2
  • IdempotencyPlug now accepts :idempotency_key, :request_payload, :hash, and :with options #2
  • IdempotencyPlug now requires :tracker option #2
  • SHA256 hashing now accepts Erlang terms instead of just binary #1 #2