ha-handler/lib/ha_handler/web.ex
2022-01-24 16:53:04 +01:00

22 lines
356 B
Elixir

defmodule HAHandler.Web do
import Plug.Conn
alias HAHandler.HAProxy
def init(opts) do
opts
end
def call(conn, _opts) do
{:ok, hostname} = :inet.gethostname()
stats = HAProxy.get_stats()
reply = "OK #{hostname}"
<> "\nPROXY: "
<> inspect(stats)
conn
|> put_resp_content_type("text/plain")
|> send_resp(200, reply)
end
end