Skip to content

zentetsukenz/ping_plug

Repository files navigation

PingPlug

CI/CD Hex.pm Coverage Status

PingPlug, a plug to echo a defined message.

Installation

The package can be installed as:

Add ping_plug to your list of dependencies in mix.exs:

def deps do
  [{:ping_plug, "~> 1.0.0"}]
end

Usage

Plug the PingPlug anywhere in your middleware stack. e.g. In Phoenix application, endpoint.ex

with return value

defmodule Endpoint do
  # snip

  plug PingPlug, path: ["_checks", "liveness"], return: "alive!"

  # snip
end

with module function execution

defmodule Checks do
  def execute do
    {:ok, "pass!"}
  end
end

defmodule Endpoint do
  # snip

  plug PingPlug, path: ["_checks", "readiness"], execute: {Checks, :execute, []}

  # snip
end

For more information, please see document.