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

40 lines
1.2 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace PhpQml\Bridge\Controller;
use PhpQml\Bridge\BridgeBundleInfo;
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).
*
* `BridgeBundleInfo` is injected purely as a deep-load canary: if the
* 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. Earlier (v0.1.1v0.2.0) this canary
* was `PublisherInterface`; switching to a dedicated info VO decouples
* the readiness probe from the publisher's evolving contract.
*/
final class HealthController
{
public function __construct(
private readonly BridgeBundleInfo $info,
) {
}
#[Route('/healthz', name: 'php_qml_bridge_healthz', methods: ['GET'])]
public function __invoke(): JsonResponse
{
return new JsonResponse([
'status' => 'ok',
'bundle' => $this->info->bundle,
'name' => $this->info->name,
]);
}
}