Files
angelicons/router.php
T
2026-02-27 23:54:26 -06:00

29 lines
446 B
PHP

<?php
$uri = parse_url($_SERVER['REQUEST_URI'])['path'];
$routes = [
'/' => 'routes/index.php',
'/ember' => 'routes/ember.php',
];
function routeToController($uri, $routes)
{
if (array_key_exists($uri, $routes)) {
require $routes[$uri];
} else {
abort();
}
}
function abort($code = 404)
{
http_response_code($code);
require "routes/404.php";
die(0);
}
routeToController($uri, $routes);