<?php
declare(strict_types=1);
// php -S 127.0.0.1:8080 -t build build/router.php
$uri = urldecode(parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH) ?? '/');
$file = __DIR__ . $uri;
if ($uri !== '/' && is_file($file)) {
    return false;
}
if (str_ends_with($uri, '.php') && is_file($file)) {
    require $file;
    return true;
}
if (is_file(__DIR__ . '/index.html')) {
    header('Content-Type: text/html; charset=utf-8');
    readfile(__DIR__ . '/index.html');
    return true;
}
return false;
