Merge branch 'known-routes'
This commit is contained in:
commit
03b7de9fcc
12
index.php
12
index.php
|
@ -38,6 +38,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>
|
||||||
';
|
';
|
||||||
}
|
}
|
||||||
|
@ -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!';
|
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