2021-01-26 12:10:54 -08:00
|
|
|
<?php
|
2021-06-10 13:15:52 -07:00
|
|
|
|
2021-01-26 12:10:54 -08:00
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use Illuminate\Routing\Controller as BaseController;
|
2024-10-02 07:36:01 -07:00
|
|
|
use Illuminate\Support\Facades\DB;
|
2021-01-26 12:10:54 -08:00
|
|
|
|
|
|
|
/**
|
2024-07-04 12:49:22 -07:00
|
|
|
* This controller provide the health route for
|
2021-01-26 12:10:54 -08:00
|
|
|
* the Snipe-IT Asset Management application.
|
|
|
|
*
|
2024-07-04 12:49:22 -07:00
|
|
|
* @version v1.0
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Http\JsonResponse
|
|
|
|
|
2021-01-26 12:10:54 -08:00
|
|
|
*/
|
|
|
|
class HealthController extends BaseController
|
|
|
|
{
|
2024-10-02 07:36:01 -07:00
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->middleware('health');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-26 12:10:54 -08:00
|
|
|
/**
|
|
|
|
* Returns a fixed JSON content ({ "status": "ok"}) which indicate the app is up and running
|
|
|
|
*/
|
2021-06-10 13:15:52 -07:00
|
|
|
public function get()
|
|
|
|
{
|
2024-10-02 07:36:01 -07:00
|
|
|
try {
|
|
|
|
|
|
|
|
if (DB::select('select 2 + 2')) {
|
|
|
|
return response()->json([
|
|
|
|
'status' => 'ok',
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
\Log::error('Could not connect to database');
|
|
|
|
return response()->json([
|
|
|
|
'status' => 'Could not connect to database',
|
|
|
|
], 500);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
die();
|
|
|
|
|
2021-01-26 12:10:54 -08:00
|
|
|
}
|
2021-06-10 13:15:52 -07:00
|
|
|
}
|