index.community/backend/lib/backend_web/controllers/instance_controller.ex

28 lines
770 B
Elixir
Raw Normal View History

2019-07-14 11:47:06 +00:00
defmodule BackendWeb.InstanceController do
use BackendWeb, :controller
import Backend.Util
alias Backend.Api
2019-07-19 18:19:53 +00:00
action_fallback(BackendWeb.FallbackController)
2019-07-14 11:47:06 +00:00
def index(conn, _params) do
instances = Api.list_instances()
render(conn, "index.json", instances: instances)
end
def show(conn, %{"id" => domain}) do
instance = Api.get_instance!(domain)
2019-07-20 17:43:37 +00:00
last_crawl = get_last_crawl(domain)
2019-07-14 11:47:06 +00:00
render(conn, "show.json", instance: instance, crawl: last_crawl)
end
# def update(conn, %{"id" => id, "instance" => instance_params}) do
# instance = Api.get_instance!(id)
# with {:ok, %Instance{} = instance} <- Api.update_instance(instance, instance_params) do
# render(conn, "show.json", instance: instance)
# end
# end
end