From b60d9481ab654476882d29984e1e645537279cee Mon Sep 17 00:00:00 2001 From: tracer Date: Sun, 23 Oct 2022 18:04:03 +0200 Subject: [PATCH] added 404 support --- src/Service/Router.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Service/Router.php b/src/Service/Router.php index b501c78..2d3d03e 100644 --- a/src/Service/Router.php +++ b/src/Service/Router.php @@ -22,6 +22,11 @@ class Router { private array $routes; + public function __construct(private readonly Template $template) + { + // empty body + } + /* * This method takes a route like /admin/users/{user} and creates a regex to match on call * More complex routes as /posts/{thread}/show/{page} are supported as well. @@ -47,7 +52,6 @@ class Router /* * Check if there is a known route and executes the callback. - * Currently no 404 handling. */ public function handleRouting(): void { @@ -66,7 +70,7 @@ class Router return; } } - // Throw a 404 result later … - die("Invalid route: $requestUri"); + $this->template->render(templateName: 'status/404.html.php'); } + } \ No newline at end of file