Fix bootstrap location, fix routes

This commit is contained in:
Sky Johnson 2024-07-17 22:18:55 -05:00
parent 61465131ae
commit 81670044f3
3 changed files with 12 additions and 11 deletions

View File

@ -4,7 +4,7 @@
// define our server path and bootstrap the request
const SERVER = '../server';
require_once SERVER.'/bootstrap/Boot.php';
require_once SERVER.'/boot/Boot.php';
// spin up our app container and the initial route
$app = new App(new Database(DB), new Request(), new Auth());
@ -15,7 +15,7 @@ installRedirect($route);
// route to the relevant module
$app->route('/', 'HomeModule')
->route('/install', 'InstallModule')
->route('/gate', 'GateModule')
->route('install', 'InstallModule')
->route('gate', 'GateModule')
->handle($route)
->cleanup();

View File

@ -45,7 +45,14 @@ class App
public function handle(string $uri): App
{
if (!isset($this->routes[$uri])) return self::fourOhFour($uri);
// if the route doesn't exist, return 404
if (!isset($this->routes[$uri])) {
http_response_code(404);
echo "404: $uri";
return $this;
}
// handle the route
$this->routes[$uri]::handle();
return $this;
}
@ -68,10 +75,4 @@ class App
$_SESSION['flash'] = [];
self::$flashes = [];
}
public static function fourOhFour(string $uri): void
{
http_response_code(404);
echo "404: $uri";
}
}

View File

@ -9,7 +9,7 @@ class GateModule
$s = App::$req->uri(1) ?? ''; // second segment
$m = App::$req->method; // request method
if (App::$auth->good() && in_array($s, self::GUEST)) redirect('/');
if (App::auth() && in_array($s, self::GUEST)) redirect('/');
if ($s == '' || $s == 'login') return self::login($m);
if ($s == 'logout' && $m == 'POST') return self::logout();