diff --git a/example.php b/example.php index 7069b26..dc5da1f 100644 --- a/example.php +++ b/example.php @@ -5,7 +5,7 @@ use WillySoft\Route as App; require __DIR__ . '/../vendor/autoload.php'; // middlewares provide a convenient mechanism for inspecting and -// filtering requests. you can imagine them as a series of "layers" +// filtering requests. you can imagine them as a series of layers // that requests must pass through before they hit your application. // a layer can be used for auth, rate limiting or anything really App::use( @@ -16,15 +16,16 @@ App::use( App::get('/', fn() => print('homepage')); +// "any" is a shorthand that does what you would expect +// allowing all of the above to pass through +App::any('/example', + fn() => print('i match on any method')); + // form is a shorthand that accepts GET and POST methods App::form('/submit', fn() => print('i match on GET and POST methods')); -// any is a shorthand that does what you would expect -App::any('/example', - fn() => print('i match on any method')); - -// if not satisfied you can use the match function which takes a +// if not satisfied you can use the match function that takes a // string of methods separated by the pipe symbol App::match('get|post|put', '/match', fn() => print('i match on any method you like')); @@ -38,9 +39,9 @@ App::get('/echo_must_supply_text/$text', fn($text) => print($text)); // group together routes and middlewares. a prefix can be added to -// prefix each route in the group with a given URI. the group will -// be skipped if the request URI does not begin with the one supplied. -// middlewares defined in here will only affect routes matched from +// prefix each route in the group with a given PATH. the group will +// be skipped if the requested PATH does not begin with the one supplied. +// middlewares defined in here will only run on routes matched from // within or any child groups App::group('/test', function() { App::use( @@ -49,12 +50,6 @@ App::group('/test', function() { // this will be matched as /test/ App::get('/', fn() => print('Testing 123')); - - // you may also define a group without a prefix - App::group('', function() { - App::get('/test', - fn() => print('Testing 456')); - }); }); // finally, since no route was matched, show a 404 page