philomena/lib/philomena_web/controllers/autocomplete/compiled_controller.ex

24 lines
551 B
Elixir
Raw Normal View History

2021-12-27 01:16:21 +01:00
defmodule PhilomenaWeb.Autocomplete.CompiledController do
use PhilomenaWeb, :controller
alias Philomena.Autocomplete
def show(conn, _params) do
autocomplete = Autocomplete.get_autocomplete()
case autocomplete do
nil ->
conn
|> put_status(:not_found)
|> configure_session(drop: true)
|> text("")
%{content: content} ->
conn
|> put_resp_header("cache-control", "public, max-age=86400")
|> configure_session(drop: true)
|> resp(200, content)
end
end
end