update
This commit is contained in:
parent
e2967f68b2
commit
ef2a6c41b4
39 changed files with 2349 additions and 30 deletions
24
lib/zoeyscomputer_web/controllers/image_json.ex
Normal file
24
lib/zoeyscomputer_web/controllers/image_json.ex
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
defmodule ZoeyscomputerWeb.ImageJSON do
|
||||
alias Zoeyscomputer.Images.Image
|
||||
|
||||
@doc """
|
||||
Renders a list of images.
|
||||
"""
|
||||
def index(%{images: images}) do
|
||||
%{data: for(image <- images, do: data(image))}
|
||||
end
|
||||
|
||||
@doc """
|
||||
Renders a single image.
|
||||
"""
|
||||
def show(%{image: image}) do
|
||||
%{data: data(image)}
|
||||
end
|
||||
|
||||
defp data(%Image{} = image) do
|
||||
%{
|
||||
id: image.id,
|
||||
file: image.file
|
||||
}
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue