mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-12 01:54:41 +08:00
Finished health action implementation
This commit is contained in:
@@ -14,7 +14,6 @@ abstract class AbstractRestAction implements RequestHandlerInterface, RequestMet
|
||||
{
|
||||
protected const ROUTE_PATH = '';
|
||||
protected const ROUTE_ALLOWED_METHODS = [];
|
||||
protected const ROUTE_CAN_BE_VERSIONED = true;
|
||||
|
||||
/** @var LoggerInterface */
|
||||
protected $logger;
|
||||
@@ -31,7 +30,6 @@ abstract class AbstractRestAction implements RequestHandlerInterface, RequestMet
|
||||
'middleware' => array_merge($prevMiddleware, [static::class], $postMiddleware),
|
||||
'path' => static::ROUTE_PATH,
|
||||
'allowed_methods' => static::ROUTE_ALLOWED_METHODS,
|
||||
'can_be_versioned' => static::ROUTE_CAN_BE_VERSIONED,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,10 +13,11 @@ use Zend\Diactoros\Response\JsonResponse;
|
||||
class HealthAction extends AbstractRestAction
|
||||
{
|
||||
private const HEALTH_CONTENT_TYPE = 'application/health+json';
|
||||
private const PASS_STATUS = 'pass';
|
||||
private const FAIL_STATUS = 'fail';
|
||||
|
||||
protected const ROUTE_PATH = '/health';
|
||||
protected const ROUTE_ALLOWED_METHODS = [self::METHOD_GET];
|
||||
protected const ROUTE_CAN_BE_VERSIONED = false;
|
||||
|
||||
/** @var AppOptions */
|
||||
private $options;
|
||||
@@ -41,7 +42,7 @@ class HealthAction extends AbstractRestAction
|
||||
$statusCode = $connected ? self::STATUS_OK : self::STATUS_SERVICE_UNAVAILABLE;
|
||||
|
||||
return new JsonResponse([
|
||||
'status' => $connected ? 'pass' : 'fail',
|
||||
'status' => $connected ? self::PASS_STATUS : self::FAIL_STATUS,
|
||||
'version' => $this->options->getVersion(),
|
||||
'links' => [
|
||||
'about' => 'https://shlink.io',
|
||||
|
||||
Reference in New Issue
Block a user