blob: 2c2d1b5090623db3af0d9fa74cdc12ff9f992fe5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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));
}
}
|