Files
php-qml/framework/php/src/Controller/HealthController.php

37 lines
1.0 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace PhpQml\Bridge\Controller;
use PhpQml\Bridge\Publisher;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
/**
* Readiness probe used by the Qt host to detect when the backend is up.
* See PLAN.md §3 (*Startup*, step 4).
*
* Publisher is injected purely as a deep-health canary: if the bridge
* bundle's autoload or container wiring is broken (e.g. a packaging build
* with a dangling vendor path-repo symlink), this controller can't even
* be constructed, so /healthz fails 500 instead of misleadingly returning
* 200 against a half-loaded bundle.
*/
final class HealthController
{
public function __construct(
private readonly Publisher $publisher,
) {
}
#[Route('/healthz', name: 'php_qml_bridge_healthz', methods: ['GET'])]
public function __invoke(): JsonResponse
{
return new JsonResponse([
'status' => 'ok',
'bundle' => $this->publisher::class,
]);
}
}