From 1991a65d4d2392a3ea5a44e3d985fdd1b94a66c7 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 7 Dec 2012 19:13:35 +0000 Subject: [PATCH] Added section about optional parameters --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index f881ca3..2bdf217 100644 --- a/README.md +++ b/README.md @@ -130,6 +130,20 @@ You can also include regular expressions with your named parameters by using the // But will not match /bob/12345 }); +## Optional Parameters + +You can specify named parameters that are optional for matching by wrapping segments in parentheses. + + Flight::route('/blog(/@year(/@month(/@day)))', function($year, $month, $day){ + // This will match the following URLS: + // /blog/2012/12/10 + // /blog/2012/12 + // /blog/2012 + // /blog + }); + +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.