2019-07-23 12:20:34 +00:00
|
|
|
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)
|
2019-07-23 12:20:34 +00:00
|
|
|
end
|
|
|
|
end
|