Skip to content
This repository was archived by the owner on May 30, 2023. It is now read-only.

Commit 3071a6c

Browse files
author
Sven Speckmaier
authored
Merge pull request #18 from ipunkt/healthcheck
Healthcheck
2 parents e549b22 + 85fee61 commit 3071a6c

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Api;
4+
5+
class HealthController extends ApiController
6+
{
7+
public function health()
8+
{
9+
if (file_put_contents(storage_path('health.txt'), date('Y-m-d H:i:s')) === false) {
10+
return $this->respond(503, 'storage unavailable');
11+
}
12+
13+
return $this->respond(200, 'healthy');
14+
}
15+
16+
private function respond($code, $message)
17+
{
18+
$data = [
19+
'status' => $code,
20+
'message' => $message,
21+
];
22+
23+
return $this->respondData($data, $code);
24+
}
25+
}

routes/api.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
return;
1616
}
1717

18+
Route::get('health', 'Api\HealthController@health');
19+
1820
Route::resource('files', 'Api\FilesController', [
1921
'only' => [
2022
'store',

0 commit comments

Comments
 (0)