Merge branch 'known-routes'

This commit is contained in:
SteamPixel 2021-03-22 09:02:02 +01:00
commit 03b7de9fcc
2 changed files with 16 additions and 0 deletions

View File

@ -38,6 +38,7 @@ function navi() {
<li><a href="'.BASEPATH.'thecasedoesnotmatter">thecasedoesnotmatter</a></li>
<li><a href="'.BASEPATH.'this-route-is-not-defined">404 Test</a></li>
<li><a href="'.BASEPATH.'this-route-is-defined">405 Test</a></li>
<li><a href="'.BASEPATH.'known-routes">known routes</a></li>
</ul>
';
}
@ -202,6 +203,17 @@ Route::methodNotAllowed(function($path, $method) {
echo 'The requested path "'.$path.'" exists. But the request method "'.$method.'" is not allowed on this path!';
});
// Return all known routes
Route::add('/known-routes', function() {
navi();
$routes = Route::getAll();
echo '<ul>';
foreach($routes as $route) {
echo '<li>'.$route['expression'].'</li>';
}
echo '</ul>';
});
// Run the Router with the given Basepath
Route::run(BASEPATH);

View File

@ -23,6 +23,10 @@ class Route {
));
}
public static function getAll(){
return self::$routes;
}
public static function pathNotFound($function) {
self::$pathNotFound = $function;
}