diff options
| author | Andrew Dolgov <fox@fakecake.org> | 2026-05-26 11:06:30 +0300 |
|---|---|---|
| committer | Andrew Dolgov <fox@fakecake.org> | 2026-05-26 11:06:30 +0300 |
| commit | fa1bccd968647f6ab5cce0ec4293b39c6fde7633 (patch) | |
| tree | a51b489a43bdfcc2688bd0855cf3e32382ad958c /classes/Handler/HealthzHandler.php | |
| parent | ab7702f0e3dd63bdeaea3cb6db138878774c3b47 (diff) | |
| download | the-epube-fa1bccd968647f6ab5cce0ec4293b39c6fde7633.tar.gz the-epube-fa1bccd968647f6ab5cce0ec4293b39c6fde7633.tar.xz | |
spaces to tabs
Diffstat (limited to 'classes/Handler/HealthzHandler.php')
| -rw-r--r-- | classes/Handler/HealthzHandler.php | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/classes/Handler/HealthzHandler.php b/classes/Handler/HealthzHandler.php index 722422c..a243b9f 100644 --- a/classes/Handler/HealthzHandler.php +++ b/classes/Handler/HealthzHandler.php @@ -11,39 +11,39 @@ use Response; class HealthzHandler implements RequestHandlerInterface { - public function handle(Request $request): Response - { - $status = "ok"; - $errors = []; - - // Test Calibre SQLite database - try { - $caldb = new PDO('sqlite:' . Config::get(Config::CALIBRE_DB)); - $caldb->query("SELECT 1 FROM books LIMIT 1"); - } catch (\PDOException $e) { - $status = "degraded"; - $errors["calibre_db"] = "Connection failed: " . $e->getMessage(); - } - - // Test main database (via ORM/Db) - try { - Db::pdo()->query("SELECT 1"); - } catch (\PDOException $e) { - $status = "degraded"; - $errors["main_db"] = "Connection failed: " . $e->getMessage(); - } - - $response = (new Response()) - ->withHeader("Content-Type", "application/json") - ->withBody(json_encode([ - "status" => $status, - "errors" => $errors, - ])); - - if ($status === "degraded") { - $response = $response->withStatus(503); - } - - return $response; - } + public function handle(Request $request): Response + { + $status = "ok"; + $errors = []; + + // Test Calibre SQLite database + try { + $caldb = new PDO('sqlite:' . Config::get(Config::CALIBRE_DB)); + $caldb->query("SELECT 1 FROM books LIMIT 1"); + } catch (\PDOException $e) { + $status = "degraded"; + $errors["calibre_db"] = "Connection failed: " . $e->getMessage(); + } + + // Test main database (via ORM/Db) + try { + Db::pdo()->query("SELECT 1"); + } catch (\PDOException $e) { + $status = "degraded"; + $errors["main_db"] = "Connection failed: " . $e->getMessage(); + } + + $response = (new Response()) + ->withHeader("Content-Type", "application/json") + ->withBody(json_encode([ + "status" => $status, + "errors" => $errors, + ])); + + if ($status === "degraded") { + $response = $response->withStatus(503); + } + + return $response; + } } |
