src/App/Controller/DefaultController.php line 17
<?php
namespace App\Controller;
use Aqarmap\Bundle\UserBundle\Services\Contracts\UserIpInfoServiceInterface;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\Routing\Attribute\Route;
class DefaultController extends AbstractController
{
#[Route(path: '/health-check/{probeType}', options: ['i18n' => false])]
public function healthCheck(Request $request, string $probeType, EntityManagerInterface $em, UserIpInfoServiceInterface $ipInfoService): JsonResponse
{
$dbConnected = false;
if ('readiness' == $probeType) {
// DB Connection Check
try {
$em->getConnection()->connect();
$dbConnected = $em->getConnection()->isConnected();
} catch (\Exception $exception) {
throw new HttpException(500, sprintf('DB Connection Error! (%s)', $exception->getMessage()));
}
}
$date = new \DateTime();
return $this->json([
'status' => 'ok',
'date' => $date->format('r'),
'db_connection' => $dbConnected,
'client_ip' => $request->getClientIp(),
]);
}
#[Route(path: '/debug', options: ['i18n' => true])]
public function debug(): Response
{
return $this->render('Default/debug.html.twig');
}
}