Added method and examples for known routes
This commit is contained in:
parent
d7775a9fad
commit
7ff0f40ec1
12
index.php
12
index.php
|
@ -37,6 +37,7 @@ function navi() {
|
||||||
<li><a href="'.BASEPATH.'thecasedoesnotmatter">thecasedoesnotmatter</a></li>
|
<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-not-defined">404 Test</a></li>
|
||||||
<li><a href="'.BASEPATH.'this-route-is-defined">405 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>
|
</ul>
|
||||||
';
|
';
|
||||||
}
|
}
|
||||||
|
@ -201,6 +202,17 @@ Route::methodNotAllowed(function($path, $method) {
|
||||||
echo 'The requested path "'.$path.'" exists. But the request method "'.$method.'" is not allowed on this path!';
|
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
|
// Run the Router with the given Basepath
|
||||||
Route::run(BASEPATH);
|
Route::run(BASEPATH);
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,10 @@ class Route {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getAll(){
|
||||||
|
return self::$routes;
|
||||||
|
}
|
||||||
|
|
||||||
public static function pathNotFound($function) {
|
public static function pathNotFound($function) {
|
||||||
self::$pathNotFound = $function;
|
self::$pathNotFound = $function;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user