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

14 lines
403 B
Elixir
Raw Normal View History

defmodule BackendWeb.SearchController do
use BackendWeb, :controller
alias Backend.Api
action_fallback(BackendWeb.FallbackController)
def index(conn, params) do
query = Map.get(params, "query")
2019-07-26 22:30:11 +00:00
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