summaryrefslogtreecommitdiffhomepage
path: root/vhosts/t/phpcon-kagawa-2025/src/PhpConKagawa2025/HealthHandler.php
diff options
context:
space:
mode:
Diffstat (limited to 'vhosts/t/phpcon-kagawa-2025/src/PhpConKagawa2025/HealthHandler.php')
-rw-r--r--vhosts/t/phpcon-kagawa-2025/src/PhpConKagawa2025/HealthHandler.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/vhosts/t/phpcon-kagawa-2025/src/PhpConKagawa2025/HealthHandler.php b/vhosts/t/phpcon-kagawa-2025/src/PhpConKagawa2025/HealthHandler.php
new file mode 100644
index 0000000..2c2d1b5
--- /dev/null
+++ b/vhosts/t/phpcon-kagawa-2025/src/PhpConKagawa2025/HealthHandler.php
@@ -0,0 +1,29 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\TinyPhpHttpd\PhpConKagawa2025;
+
+use Psr\Http\Message\ResponseFactoryInterface;
+use Psr\Http\Message\ResponseInterface;
+use Psr\Http\Message\ServerRequestInterface;
+use Psr\Http\Message\StreamFactoryInterface;
+use Psr\Http\Server\RequestHandlerInterface;
+
+final readonly class HealthHandler implements RequestHandlerInterface
+{
+ public function __construct(
+ private ResponseFactoryInterface $responseFactory,
+ private StreamFactoryInterface $streamFactory,
+ ) {
+ }
+
+ public function handle(ServerRequestInterface $request): ResponseInterface
+ {
+ $body = 'OK';
+
+ return $this->responseFactory->createResponse(200)
+ ->withHeader('Content-Type', 'text/plain; charset=UTF-8')
+ ->withBody($this->streamFactory->createStream($body));
+ }
+}