Update
This commit is contained in:
parent
f90a7133bc
commit
00ecbadeca
29 changed files with 871 additions and 12 deletions
23
lib/nulla_web/controllers/api/announce_json.ex
Normal file
23
lib/nulla_web/controllers/api/announce_json.ex
Normal file
|
@ -0,0 +1,23 @@
|
|||
defmodule NullaWeb.Api.AnnounceJSON do
|
||||
alias Nulla.Announces.Announce
|
||||
|
||||
@doc """
|
||||
Renders a list of announces.
|
||||
"""
|
||||
def index(%{announces: announces}) do
|
||||
%{data: for(announce <- announces, do: data(announce))}
|
||||
end
|
||||
|
||||
@doc """
|
||||
Renders a single announce.
|
||||
"""
|
||||
def show(%{announce: announce}) do
|
||||
%{data: data(announce)}
|
||||
end
|
||||
|
||||
defp data(%Announce{} = announce) do
|
||||
%{
|
||||
id: announce.id
|
||||
}
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue