1
0
mirror of https://github.com/mgerb/classic-wow-forums synced 2026-01-11 09:32:51 +00:00
Files
classic-wow-forums/lib/myapp_web/response.ex
2017-12-31 20:19:44 -06:00

23 lines
392 B
Elixir

defmodule MyAppWeb.Response do
# error handling based on http status
def json(conn, data) do
output = cond do
conn.status && conn.status >= 400 ->
%{
error: %{
status: conn.status,
message: data,
}
}
true -> %{
data: data
}
end
Phoenix.Controller.json(conn, output)
end
end