healthcheck improvements
All checks were successful
CI/CD Pipeline / build (push) Successful in 31s

This commit is contained in:
2026-03-09 15:38:49 -06:00
parent 1da9432502
commit 876602fb4a
4 changed files with 20 additions and 13 deletions

View File

@@ -1,7 +0,0 @@
defmodule ElixirAiWeb.HealthController do
use ElixirAiWeb, :controller
def index(conn, _params) do
json(conn, %{status: "ok"})
end
end

View File

@@ -1,6 +1,9 @@
defmodule ElixirAiWeb.Endpoint do defmodule ElixirAiWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :elixir_ai use Phoenix.Endpoint, otp_app: :elixir_ai
# Health check plug - runs before everything else to avoid logging and unnecessary processing
plug ElixirAiWeb.Plugs.HealthCheck
# The session will be stored in the cookie and signed, # The session will be stored in the cookie and signed,
# this means its contents can be read but not tampered with. # this means its contents can be read but not tampered with.
# Set :encryption_salt if you would also like to encrypt it. # Set :encryption_salt if you would also like to encrypt it.

View File

@@ -0,0 +1,17 @@
defmodule ElixirAiWeb.Plugs.HealthCheck do
@moduledoc """
A lightweight health check plug that responds before hitting the router.
This avoids unnecessary processing and logging for health check requests.
"""
import Plug.Conn
def init(opts), do: opts
def call(%Plug.Conn{request_path: "/health"} = conn, _opts) do
conn
|> send_resp(200, ~s({"status":"ok"}))
|> halt()
end
def call(conn, _opts), do: conn
end

View File

@@ -14,12 +14,6 @@ defmodule ElixirAiWeb.Router do
plug :accepts, ["json"] plug :accepts, ["json"]
end end
scope "/", ElixirAiWeb, log: false do
pipe_through :api
get "/health", HealthController, :index
end
scope "/", ElixirAiWeb do scope "/", ElixirAiWeb do
pipe_through :browser pipe_through :browser