Updated Intro.pod
Sebastian Riedel [Wed, 9 Nov 2005 16:00:03 +0000 (16:00 +0000)]
lib/Catalyst.pm
lib/Catalyst/Manual/Intro.pod

index fd2c65b..7e0cc98 100644 (file)
@@ -1781,6 +1781,8 @@ Arthur Bergman
 
 Autrijus Tang
 
+Brian Cassidy
+
 Christian Hansen
 
 Christopher Hicks
index abd7ed3..b96b1b9 100644 (file)
@@ -317,10 +317,24 @@ Catalyst supports several types of actions:
 
 =item * B<Literal>
 
+    package MyApp::C::My::Controller;
     sub bar : Path('foo/bar') { }
 
+Literal C<Path> 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<Path> definition empty, it will match on the namespace root.
+The above code matches http://localhost:3000/my/controller.
+
 =item * B<Regex>
 
     sub bar : Regex('^item(\d+)/order(\d+)$') { }
@@ -340,8 +354,16 @@ the regex. To achieve the above, you should consider using a C<LocalRegex> actio
     sub bar : LocalRegex('^widget(\d+)$') { }
 
 LocalRegex actions act locally. If you were to use C<bar> in
-C<MyApp::Controller::Catalogue>, the above example would match urls like
-http://localhost:3000/catalogue/widget23.
+C<MyApp::Controller::Catalog>, 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<default> isn't acting how you would expect, look at using a
+L<Literal> C<Path> action (with an empty path string). The difference
+being that C<Path> takes arguments relative from the namespace and
+C<default> takes arguments relative from the root.
+
 =item * B<index : Private>
 
 C<index> is much like C<default> except that it takes no arguments