conn = $conn; $this->options = $options; } /** * Handles a request and produces a response. * * May call other collaborating code to generate the response. */ public function handle(ServerRequestInterface $request): ResponseInterface { try { $connected = $this->conn->ping(); } catch (Throwable $e) { $connected = false; } $statusCode = $connected ? self::STATUS_OK : self::STATUS_SERVICE_UNAVAILABLE; return new JsonResponse([ 'status' => $connected ? self::PASS_STATUS : self::FAIL_STATUS, 'version' => $this->options->getVersion(), 'links' => [ 'about' => 'https://shlink.io', 'project' => 'https://github.com/shlinkio/shlink', ], ], $statusCode, ['Content-type' => self::HEALTH_CONTENT_TYPE]); } }