UpstatePhoenix.Plug (upstate_phoenix v0.1.1)

Copy Markdown View Source

Answers GET /upstate/health with Upstate's app-health schema 1. Every other request passes through untouched, so it can sit in the endpoint before the router:

# lib/my_app_web/endpoint.ex
plug UpstatePhoenix.Plug, otp_app: :my_app

Put it above plug Plug.Telemetry so the once-a-minute poll stays out of request logs.

Auth

The token is UPSTATE_HEALTH_TOKEN, read at request time (or config :upstate_phoenix, token: ...). With no token configured the path answers 404, as if nothing were installed. A missing or wrong bearer token answers 401. Tokens are compared as SHA-256 digests in constant time.

Options

Options come from the plug call, then config :upstate_phoenix, ..., then defaults:

  • :otp_app - your app. Used to find :ecto_repos when :repos is not set.
  • :repos - repos to check for reachability and pending migrations. Each entry is a repo module or {repo, migrations_paths: [...]}. Defaults to the app's :ecto_repos. Set migrations_paths: [] when another application owns the schema; migration status is then unknown (null) while database reachability is still checked.
  • :oban - the Oban instance name (default Oban), or false to report no job system.
  • :environment - shown as phoenix.environment. Defaults to the Mix env the package was compiled in ("prod" in a release).