From: Sebastian Riedel Date: Wed, 9 Nov 2005 16:00:03 +0000 (+0000) Subject: Updated Intro.pod X-Git-Tag: 5.7099_04~987 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=0cf56dbcd3a060c815aa5e66a67709bb51efd80d Updated Intro.pod --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index fd2c65b..7e0cc98 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -1781,6 +1781,8 @@ Arthur Bergman Autrijus Tang +Brian Cassidy + Christian Hansen Christopher Hicks diff --git a/lib/Catalyst/Manual/Intro.pod b/lib/Catalyst/Manual/Intro.pod index abd7ed3..b96b1b9 100644 --- a/lib/Catalyst/Manual/Intro.pod +++ b/lib/Catalyst/Manual/Intro.pod @@ -317,10 +317,24 @@ Catalyst supports several types of actions: =item * B + package MyApp::C::My::Controller; sub bar : Path('foo/bar') { } +Literal C actions will act relative to their current namespace. The above +example matches only http://localhost:3000/my/controller/foo/bar. If you start +your path with a forward slash, it will match from the root. Example: + + package MyApp::C::My::Controller; + sub bar : Path('/foo/bar') { } + Matches only http://localhost:3000/foo/bar. + package MyApp::C::My::Controller; + sub bar : Path { } + +By leaving the C definition empty, it will match on the namespace root. +The above code matches http://localhost:3000/my/controller. + =item * B sub bar : Regex('^item(\d+)/order(\d+)$') { } @@ -340,8 +354,16 @@ the regex. To achieve the above, you should consider using a C actio sub bar : LocalRegex('^widget(\d+)$') { } LocalRegex actions act locally. If you were to use C in -C, the above example would match urls like -http://localhost:3000/catalogue/widget23. +C, the above example would match urls like +http://localhost:3000/catalog/widget23. + +If you omit the "C<^>" from your regex, then it will match any depth from the +controller and not immediately off of the controller name. The following example +differes from the above code in that it will match +http://localhost:3000/catalog/foo/widget23 as well. + + package MyApp::Controller::Catalog; + sub bar : LocalRegex('widget(\d+)$') { } For both LocalRegex and Regex actions, if you use capturing parentheses to extract values within the matching URL ("widget23" would capture "23" in the @@ -408,6 +430,11 @@ Called when no other action matches. Could be used, for example, for displaying a generic frontpage for the main app, or an error page for individual controllers. +If C isn't acting how you would expect, look at using a +L C action (with an empty path string). The difference +being that C takes arguments relative from the namespace and +C takes arguments relative from the root. + =item * B C is much like C except that it takes no arguments