This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
defmodule ElixirAiWeb.HealthController do
|
||||
use ElixirAiWeb, :controller
|
||||
|
||||
def index(conn, _params) do
|
||||
json(conn, %{status: "ok"})
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,9 @@
|
||||
defmodule ElixirAiWeb.Endpoint do
|
||||
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,
|
||||
# this means its contents can be read but not tampered with.
|
||||
# Set :encryption_salt if you would also like to encrypt it.
|
||||
|
||||
17
lib/elixir_ai_web/plugs/health_check.ex
Normal file
17
lib/elixir_ai_web/plugs/health_check.ex
Normal 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
|
||||
@@ -14,12 +14,6 @@ defmodule ElixirAiWeb.Router do
|
||||
plug :accepts, ["json"]
|
||||
end
|
||||
|
||||
scope "/", ElixirAiWeb, log: false do
|
||||
pipe_through :api
|
||||
|
||||
get "/health", HealthController, :index
|
||||
end
|
||||
|
||||
scope "/", ElixirAiWeb do
|
||||
pipe_through :browser
|
||||
|
||||
|
||||
Reference in New Issue
Block a user