index.community/backend/lib/backend_web/controllers/search_controller.ex
2019-07-26 22:30:11 +00:00

14 lines
403 B
Elixir

defmodule BackendWeb.SearchController do
use BackendWeb, :controller
alias Backend.Api
action_fallback(BackendWeb.FallbackController)
def index(conn, params) do
query = Map.get(params, "query")
from = Map.get(params, "after", "0") |> String.to_integer()
%{hits: hits, next: next} = Api.search_instances(query, from)
render(conn, "index.json", hits: hits, next: next)
end
end