HeartCheck.Plug (heartcheck v0.4.3) View Source

Plug to mount heartcheck in your plug-compatible app

Add to your router:


def MyApp.Router
  use Plug.Router
  # (...)
  forward "/monitoring", to: HeartCheck.Plug, heartcheck: MyHeart
end

Or phoenix pipeline (note the different syntax):


def MyApp.Router
  use MyApp.Web, :router

  # (...)

  scope "/", MyApp do
    pipe_through :browser

    # (...)

    forward "/monitoring", HeartCheck.Plug, heartcheck: MyHeart
  end
end

In any of the cases above, if you wish to cache the HeartCheck results for a time, mount the HeartCheck.CachingPlug instead of HeartCheck.Plug:


def MyApp.Router
  use Plug.Router

  require HeartCheck

  # (...)

  forward "/monitoring", to: HeartCheck.CachingPlug, heartcheck: MyHeart
end

or on phoenix:


def MyApp.Router
  use MyApp.Web, :router

  require HeartCheck

  # (...)

  scope "/", MyApp do
    pipe_through :browser

    # (...)

    forward "/monitoring", HeartCheck.CachingPlug, heartcheck: MyHeart
  end
end