X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FRouteMatching.pod;h=e91b5603d12d05d06c683a5e6a22d48283e9b83a;hp=586736833c45b9cfd4758421a547f69979fabfc6;hb=75ce30d0f208d49ead0134ab45fc2f45f72d6023;hpb=25ca36c2fb3547600772a73c722a30b469ad632f diff --git a/lib/Catalyst/RouteMatching.pod b/lib/Catalyst/RouteMatching.pod index 5867368..e91b560 100644 --- a/lib/Catalyst/RouteMatching.pod +++ b/lib/Catalyst/RouteMatching.pod @@ -23,7 +23,7 @@ is a simple example: extends 'Catalyst::Controller'; - sub find :Path('') Args(Int) { + sub find :Path('') Args('Int') { my ($self, $c, $int) = @_; } @@ -42,11 +42,18 @@ easily understood and declarative actions. More than one argument may be added by comma separating your type constraint names, for example: + use Types::Standard qw/Int Str/; + sub find :Path('') Args(Int,Int,Str) { my ($self, $c, $int1, $int2, $str) = @_; } -Would require three arguments, an integer, integer and a string. +Would require three arguments, an integer, integer and a string. Note in this example we +constrained the args using imported types via L. Although you may use +stringy Moose types, we recommend imported types since this is less ambiguous to your readers. +If you want to use Moose stringy types. you must quote them (either "Int" or 'Int' is fine). + +Conversely, you should not quote types that are imported! =head3 Using type constraints in a controller @@ -60,7 +67,7 @@ the L library that is packaged with L: use Moose; use MooseX::MethodAttributes; - use Types::Standard qw/StrMatch/; + use Types::Standard qw/StrMatch Int/; extends 'Catalyst::Controller'; @@ -111,6 +118,8 @@ Using type constraints in Chained actions works the same as it does for Path and actions. The only difference is that you may declare type constraints on CaptureArgs as well as Args. For Example: + use Types::Standard qw/Int Tuple/; + sub chain_base :Chained(/) CaptureArgs(1) { } sub any_priority_chain :GET Chained(chain_base) PathPart('') Args(1) { }