Any optional parameters that are not matched will be passed in as NULL.
### Wildcards
Matching is only done on individual URL segments. If you want to match multiple segments you can use the `*` wildcard.
@ -80,4 +95,39 @@ To route all requests to a single callback, you can do:
Flight::route('*', function(){
// Do something
});
});
### Passing
You can pass execution on to the next matching route by returning true from your callback function.
Flight::route('/user/@name', function($name){
// Check some condition
if ($name != "Bob") {
// Continue to next route
return true;
}
});
Flight::route('/user/*', function(){
// This will get called
});
### Route Info
If you want to inspect the matching route information, you can request for the route object to be passed to your callback by passing in true as the third parameter in the route method. The route object will always be the last parameter passed to your callback function.
Flight::route('/', function($route){
// Array of HTTP methods matched against
$route->methods;
// Array of named parameters
$route->params;
// Matching regular expression
$route->regex;
// Contains the contents of any '*' used in the URL pattern