mobilizon/lib/eventos_web/controllers/search_controller.ex
Thomas Citharel cac4dd3ca3
Search
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2018-06-06 18:16:14 +02:00

21 lines
512 B
Elixir

defmodule EventosWeb.SearchController do
@moduledoc """
Controller for Search
"""
use EventosWeb, :controller
alias Eventos.Events
alias Eventos.Actors
action_fallback EventosWeb.FallbackController
def search(conn, %{"name" => name}) do
events = Events.find_events_by_name(name)
case Actors.search(name) do # find already saved accounts
{:ok, actors} ->
render(conn, "search.json", events: events, actors: actors)
{:error, err} -> json(conn, err)
end
end
end