Added some small notes.

This commit is contained in:
tracer 2022-10-23 12:11:57 +02:00
parent f571d7548a
commit e9fd8e153d
1 changed files with 11 additions and 1 deletions

View File

@ -6,6 +6,11 @@ namespace App\Service;
use App\Entity\Route; use App\Entity\Route;
use Closure; use Closure;
/*
* A small router implementation for the address book demo.
* Currently it doesn't handle GET requests, as not needed.
* But if I reuse the code in my bind Api I'll enable GET as well.
*/
class Router class Router
{ {
private array $routes; private array $routes;
@ -31,6 +36,10 @@ class Router
$this->routes[] = $route; $this->routes[] = $route;
} }
/*
* Check is there is a known route and executed the callback.
* Currently no 404 handling.
*/
public function handleRouting(): void public function handleRouting(): void
{ {
$requestUri = $_SERVER['REQUEST_URI']; $requestUri = $_SERVER['REQUEST_URI'];
@ -48,6 +57,7 @@ class Router
return; return;
} }
} }
// Throw a 404 result later …
die("Invalid route: $requestUri"); die("Invalid route: $requestUri");
} }
} }