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

39 lines
1.2 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace PhpQml\Bridge\Controller;
use PhpQml\Bridge\PublisherInterface;
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).
*
* `PublisherInterface` 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. The response includes the
* concrete class name so packagers can detect a wrong-implementation
* deployment from the canary value alone.
*/
final class HealthController
{
public function __construct(
private readonly PublisherInterface $publisher,
) {
}
#[Route('/healthz', name: 'php_qml_bridge_healthz', methods: ['GET'])]
public function __invoke(): JsonResponse
{
return new JsonResponse([
'status' => 'ok',
'bundle' => $this->publisher::class,
]);
}
}