2026-05-02 01:05:19 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace PhpQml\Bridge\Controller;
|
|
|
|
|
|
2026-05-03 13:19:58 +02:00
|
|
|
use PhpQml\Bridge\Publisher;
|
2026-05-02 01:05:19 +02:00
|
|
|
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).
|
2026-05-03 13:19:58 +02:00
|
|
|
*
|
|
|
|
|
* 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.
|
2026-05-02 01:05:19 +02:00
|
|
|
*/
|
|
|
|
|
final class HealthController
|
|
|
|
|
{
|
2026-05-03 13:19:58 +02:00
|
|
|
public function __construct(
|
|
|
|
|
private readonly Publisher $publisher,
|
|
|
|
|
) {
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-02 01:05:19 +02:00
|
|
|
#[Route('/healthz', name: 'php_qml_bridge_healthz', methods: ['GET'])]
|
|
|
|
|
public function __invoke(): JsonResponse
|
|
|
|
|
{
|
2026-05-03 13:19:58 +02:00
|
|
|
return new JsonResponse([
|
|
|
|
|
'status' => 'ok',
|
|
|
|
|
'bundle' => $this->publisher::class,
|
|
|
|
|
]);
|
2026-05-02 01:05:19 +02:00
|
|
|
}
|
|
|
|
|
}
|