Render a "delete" JSON response with the UUID of the deleted item.

This commit is contained in:
2026-05-04 08:20:52 +02:00
parent 44bf1796d0
commit d1b05db2d7
2 changed files with 5 additions and 1 deletions

View File

@ -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

View File

@ -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,