mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 00:26:30 +00:00
TwitterAPI: Return proper error when healthcheck is disabled
This commit is contained in:
parent
272271d939
commit
35090f6eac
3 changed files with 6 additions and 2 deletions
1
changelog.d/healthcheck-disabled-error.fix
Normal file
1
changelog.d/healthcheck-disabled-error.fix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
TwitterAPI: Return proper error when healthcheck is disabled
|
|
@ -345,13 +345,16 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
|
||||||
end
|
end
|
||||||
|
|
||||||
def healthcheck(conn, _params) do
|
def healthcheck(conn, _params) do
|
||||||
with true <- Config.get([:instance, :healthcheck]),
|
with {:cfg, true} <- {:cfg, Config.get([:instance, :healthcheck])},
|
||||||
%{healthy: true} = info <- Healthcheck.system_info() do
|
%{healthy: true} = info <- Healthcheck.system_info() do
|
||||||
json(conn, info)
|
json(conn, info)
|
||||||
else
|
else
|
||||||
%{healthy: false} = info ->
|
%{healthy: false} = info ->
|
||||||
service_unavailable(conn, info)
|
service_unavailable(conn, info)
|
||||||
|
|
||||||
|
{:cfg, false} ->
|
||||||
|
service_unavailable(conn, %{"error" => "Healthcheck disabled"})
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
service_unavailable(conn, %{})
|
service_unavailable(conn, %{})
|
||||||
end
|
end
|
||||||
|
|
|
@ -106,7 +106,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
|
||||||
|> get("/api/pleroma/healthcheck")
|
|> get("/api/pleroma/healthcheck")
|
||||||
|> json_response_and_validate_schema(503)
|
|> json_response_and_validate_schema(503)
|
||||||
|
|
||||||
assert response == %{}
|
assert response == %{"error" => "Healthcheck disabled"}
|
||||||
end
|
end
|
||||||
|
|
||||||
test "returns 200 when healthcheck enabled and all ok", %{conn: conn} do
|
test "returns 200 when healthcheck enabled and all ok", %{conn: conn} do
|
||||||
|
|
Loading…
Reference in a new issue