proxMon/server/lib/server_web/router.ex
Carsten 579d7fc6e8 feat(server): public GET /health endpoint for uptime monitors
Returns 200 with {status: ok, version, db: ok} when SQLite is reachable,
503 when the DB probe fails. Unauthenticated so external monitors can
poll without credentials.
2026-04-22 08:48:14 +02:00

63 lines
1.4 KiB
Elixir

defmodule ServerWeb.Router do
use ServerWeb, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_live_flash
plug :put_root_layout, html: {ServerWeb.Layouts, :root}
plug :protect_from_forgery
plug :put_secure_browser_headers
end
pipeline :require_auth do
plug ServerWeb.Plugs.RequireAuth
end
pipeline :api do
plug :accepts, ["json"]
end
# Public login/logout
scope "/", ServerWeb do
pipe_through :browser
get "/login", AuthController, :login
post "/login", AuthController, :create
delete "/logout", AuthController, :delete
end
# Authenticated dashboard (LiveView)
scope "/", ServerWeb do
pipe_through [:browser, :require_auth]
live_session :authenticated, on_mount: {ServerWeb.LiveAuth, :require_authenticated} do
live "/", OverviewLive, :index
live "/hosts/:name", HostDetailLive, :show
live "/vms", VmSearchLive, :index
live "/admin/hosts", AdminHostsLive, :index
end
end
scope "/api", ServerWeb do
pipe_through :api
get "/hosts/:name", HostController, :show
end
scope "/", ServerWeb do
pipe_through :api
get "/health", HealthController, :show
end
if Application.compile_env(:server, :dev_routes) do
import Phoenix.LiveDashboard.Router
scope "/dev" do
pipe_through :browser
live_dashboard "/dashboard", metrics: ServerWeb.Telemetry
end
end
end