24 lines
418 B
Elixir
24 lines
418 B
Elixir
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
|