Packages

A jsonapi.org serializer and optional server implementation in Elixir. Relax can be used as a standalone API with Relax.Router and Relax.Resources, or integrated into Phoenix using Relax.Serializer.

Current section

Files

Jump to
relax lib relax resource update.ex
Raw

lib/relax/resource/update.ex

defmodule Relax.Resource.Update do
use Behaviour
@doc "Updates resource, sets conn status and body"
defcallback update(conn :: Plug.Conn.t, id :: binary) :: Plug.Conn.t
defmacro __using__(_) do
quote do
@behaviour Relax.Resource.Update
def update(conn, _id), do: conn
defoverridable [update: 2]
patch "/:id", do: update(var!(conn), var!(id))
put "/:id", do: update(var!(conn), var!(id))
end
end
end