esrom/ui/lib/ui_web/controllers/page_controller.ex
Pim Kunis 2140a165fd Fix if real ip not present in headers.
Exclude more addresses from telegram messages.
2019-10-30 20:31:58 +01:00

20 lines
455 B
Elixir

defmodule UiWeb.PageController do
use UiWeb, :controller
alias Phoenix.LiveView
def index(conn, _params) do
send_resp(conn, 204, "")
end
def instructions(conn, _params) do
render(conn, :instructions)
end
def morse(conn, _params) do
ip = case Plug.Conn.get_req_header(conn, "x-real-ip") do
[h|_tl] -> h
_ -> "0.0.0.0"
end
LiveView.Controller.live_render(conn, UiWeb.MorseLive, session: %{ip: ip})
end
end