1
0
Fork 0
mirror of synced 2024-07-03 05:31:38 +12:00

Updated health response

This commit is contained in:
eldadfux 2019-09-20 12:08:24 +03:00
parent 87db473c70
commit 8c4d22cb74

View file

@ -8,14 +8,14 @@ use Storage\Storage;
use Appwrite\ClamAV\Network; use Appwrite\ClamAV\Network;
$utopia->get('/v1/health') $utopia->get('/v1/health')
->desc('Check DB Health') ->desc('Check API HTTP Health')
->label('scope', 'health.read') ->label('scope', 'health.read')
->label('sdk.namespace', 'health') ->label('sdk.namespace', 'health')
->label('sdk.method', 'getDB') ->label('sdk.method', 'getDB')
->label('docs', false) ->label('docs', false)
->action( ->action(
function () use ($response, $register) { function () use ($response) {
$response->json(array('OK')); $response->json(['status' => 'OK']);
} }
); );
@ -29,7 +29,7 @@ $utopia->get('/v1/health/db')
function () use ($response, $register) { function () use ($response, $register) {
$register->get('db'); /* @var $db PDO */ $register->get('db'); /* @var $db PDO */
$response->json(array('OK')); $response->json(['status' => 'OK']);
} }
); );
@ -43,7 +43,7 @@ $utopia->get('/v1/health/cache')
function () use ($response, $register) { function () use ($response, $register) {
$register->get('cache'); /* @var $cache Predis\Client */ $register->get('cache'); /* @var $cache Predis\Client */
$response->json(array('OK')); $response->json(['status' => 'OK']);
} }
); );
@ -115,15 +115,15 @@ $utopia->get('/v1/health/storage/local')
function () use ($response) { function () use ($response) {
$device = new Local(); $device = new Local();
if (!is_readable($device->getRoot())) { if (!is_readable($device->getRoot(). '/..')) {
throw new Exception('Device is not readable'); throw new Exception('Device is not readable');
} }
if (!is_writable($device->getRoot())) { if (!is_writable($device->getRoot(). '/..')) {
throw new Exception('Device is not writable'); throw new Exception('Device is not writable');
} }
$response->json(array('OK')); $response->json(['status' => 'OK']);
} }
); );
@ -151,7 +151,7 @@ $utopia->get('/v1/health/stats')
->label('sdk.method', 'getStats') ->label('sdk.method', 'getStats')
->label('docs', false) ->label('docs', false)
->action( ->action(
function () use ($request, $response, $register, $project) { function () use ($response, $register) {
$device = Storage::getDevice('local'); $device = Storage::getDevice('local');
$cache = $register->get('cache'); $cache = $register->get('cache');