Render a "delete" JSON response with the UUID of the deleted item.
This commit is contained in:
@ -37,7 +37,7 @@ defmodule GenericRestServerWeb.ItemController do
|
|||||||
item = Items.get_item!(conn.assigns.current_scope, id)
|
item = Items.get_item!(conn.assigns.current_scope, id)
|
||||||
|
|
||||||
with {:ok, %Item{}} <- Items.delete_item(conn.assigns.current_scope, item) do
|
with {:ok, %Item{}} <- Items.delete_item(conn.assigns.current_scope, item) do
|
||||||
send_resp(conn, :no_content, "")
|
render(conn, :delete, item: item)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -15,6 +15,10 @@ defmodule GenericRestServerWeb.ItemJSON do
|
|||||||
%{item: data(item)}
|
%{item: data(item)}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def delete(%{item: item}) do
|
||||||
|
%{deleted: item.id}
|
||||||
|
end
|
||||||
|
|
||||||
defp data(%Item{} = item) do
|
defp data(%Item{} = item) do
|
||||||
%{
|
%{
|
||||||
id: item.id,
|
id: item.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user