Feature/826 healthcheck endpoint
[akkoma] / lib / pleroma / web / twitter_api / controllers / util_controller.ex
index 8665e058a39ff596fa2bd1f8b576a965eceae67a..197a89966ca9f02a63b946f7f1f978f7a83b0aad 100644 (file)
@@ -363,4 +363,17 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
   def captcha(conn, _params) do
     json(conn, Pleroma.Captcha.new())
   end
+
+  def healthcheck(conn, _params) do
+    info = Pleroma.Healthcheck.system_info()
+
+    conn =
+      if info.healthy do
+        conn
+      else
+        Plug.Conn.put_status(conn, :service_unavailable)
+      end
+
+    json(conn, info)
+  end
 end