Skip to content

erickgnavar/sanito

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sanito

Plug health check module, used for example for container healthcheck

Installation

If available in Hex, the package can be installed by adding sanito to your list of dependencies in mix.exs:

def deps do
  [
    {:sanito, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/sanito.

Usage

Define the plug module in endpoint.ex, this will expose an endpoint for health check, this endpoint won't send anything to the logger so it is safe to use without worrying about generating tons of logs.

defmodule MyAppWeb.Endpoint do
  use Phoenix.Endpoint, otp_app: :my_app

  ...

  plug Sanito.Plug, path: "/health", plugins: [{Sanito.Plugins.EctoPlugin, repo: MyApp.Repo}, MyCustomPlugin]
  ...

  plug Plug.RequestId
  plug Plug.Telemetry, event_prefix: [:phoenix, :endpoint]

  ...

  plug MyAppWeb.Router
end

Custom plugins must implement Sanito.PluginBehaviour.

About

Elixir plug health check, allow to define different health checks and expose them in a path

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages