Skip to content

Commit

Permalink
Add health check endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
zacksiri committed Mar 4, 2024
1 parent 7004c08 commit f255c74
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/polar_web/endpoint.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ defmodule PolarWeb.Endpoint do
websocket: [connect_info: [session: @session_options]],
longpoll: [connect_info: [session: @session_options]]

plug PolarWeb.Plugs.HealthCheck

# Serve at "/" the static files from "priv/static" directory.
#
# You should set gzip to true if you are running phx.digest
Expand Down
18 changes: 18 additions & 0 deletions lib/polar_web/plugs/health_check.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
defmodule PolarWeb.Plugs.HealthCheck do
import Plug.Conn

def init(opts), do: opts

def call(%Plug.Conn{request_path: "/health"} = conn, _opts) do
conn
|> send_resp(
200,
Jason.encode!(%{
status: "Polar serving images."
})
)
|> halt()
end

def call(conn, _opts), do: conn
end

0 comments on commit f255c74

Please sign in to comment.