diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-11-24 04:58:38 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-11-24 04:58:38 +0900 |
| commit | 67094790d2d9db5c99e7c136f49061a78698e57d (patch) | |
| tree | 02feb966e74c7c2d1b6a77d8310502aa9758649b /vhosts/t/phpcon-kagawa-2025/src/PhpConKagawa2025/NotFoundHandler.php | |
| parent | a071111365f9760b2f97fa3f6e12aee9f75dd15d (diff) | |
| download | nil.ninja-67094790d2d9db5c99e7c136f49061a78698e57d.tar.gz nil.ninja-67094790d2d9db5c99e7c136f49061a78698e57d.tar.zst nil.ninja-67094790d2d9db5c99e7c136f49061a78698e57d.zip | |
Add vhosts/t/phpcon-kagawa-2025/
Diffstat (limited to 'vhosts/t/phpcon-kagawa-2025/src/PhpConKagawa2025/NotFoundHandler.php')
| -rw-r--r-- | vhosts/t/phpcon-kagawa-2025/src/PhpConKagawa2025/NotFoundHandler.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/vhosts/t/phpcon-kagawa-2025/src/PhpConKagawa2025/NotFoundHandler.php b/vhosts/t/phpcon-kagawa-2025/src/PhpConKagawa2025/NotFoundHandler.php new file mode 100644 index 0000000..0d5b33f --- /dev/null +++ b/vhosts/t/phpcon-kagawa-2025/src/PhpConKagawa2025/NotFoundHandler.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 NotFoundHandler implements RequestHandlerInterface +{ + public function __construct( + private ResponseFactoryInterface $responseFactory, + private StreamFactoryInterface $streamFactory, + ) { + } + + public function handle(ServerRequestInterface $request): ResponseInterface + { + $body = '404 Not Found'; + + return $this->responseFactory->createResponse(404) + ->withHeader('Content-Type', 'text/plain; charset=UTF-8') + ->withBody($this->streamFactory->createStream($body)); + } +} |
