X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FIntro.pod;h=b96b1b9c8630b54d94e57ea9b754f57faac44da5;hp=abd7ed3cd4003c7ad4615249b2f1a3162a371514;hb=0cf56dbcd3a060c815aa5e66a67709bb51efd80d;hpb=0c74cb084f1428fab8139a80c43ac83b2a68c94c 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