SignificaUtils.HealthRouter (significa_utils v0.0.1-main-a68c9941c5d644aa896c6919c6ccfc2aa420ea48)

View Source

Simple all-in-one health router (with handlers).

Usage:

In you router, use Phoenix.Router.html.forward/4 to use this router (or match).

forward "/healthz", SignificaUtils.HealthRouter,
  repo: MyProject.Repo,
  otp_app: :my_project

It will create 3 routes under the specified prefix (/healthz in the example above):

  • /: Returns OK (we include content as it is sometimes strange to have zero length responses).
  • /db: Uses ecto and the provided repo to return the version of the latest Ecto migration.
  • /version: Returns the value of the :app_version env, specified in your otp_app. Make sure you have used Application.put_env/3 or defined the app_version in your configs:
    config :my_project,
      app_version: "1.2.3"