Relax.Resource.Delete behaviour
Include in your resource to respond to DELETE /:id
Typically brought into your resource via use Relax.Resource
.
Update defines two callback behaviours, one of which (delete/2
) must be
implemented.
In addition this module includes the behaviours:
Relax.Resource.FetchOne
- to find the model to update.Relax.Resource.Fetchable
- to find the model to update.
Summary
halt_not_found(model, conn) |
Types
Functions
Callbacks
Specs:
- delete(Plug.Conn.t, %{}) :: Plug.Conn.t | {atom, %{}} | %{}
Delete a record.
Receives the conn and the model as found by fetch_one/2
.
def delete(_conn, post) do
MyApp.Repo.delete!(post)
end
A conn may also be returned:
def delete(conn), do: halt send_resp(conn, 401, "nope")
Specs:
- delete_resource(Plug.Conn.t, id) :: Plug.Conn.t
This callback can be used to completely override the delete action.
It accepts a Plug.Conn and must return a Plug.Conn.t