.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Mason::Plugin::RouterSimple 3pm" .TH Mason::Plugin::RouterSimple 3pm "2022-05-27" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Mason::Plugin::RouterSimple \- Specify routes for page components .SH "VERSION" .IX Header "VERSION" version 0.07 .SH "SYNOPSIS" .IX Header "SYNOPSIS" In a top-level component '/archives.mc': .PP .Vb 3 \& <%class> \& route ":section/{year:[0\-9]{4}}/{month:[0\-9]{2}}"; \& \& \& Archives for <% $.section %> \& For the month of <% $.month %>/<% $.year %> .Ve .PP then \f(CW\*(C`/archives/news/2010/02\*(C'\fR outputs .PP .Vb 2 \& Archives for news \& For the month of 2010/02 .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" See Mason::Manual::RequestDispatch for background on how request paths get mapped to page components. .PP This plugin allows you to parse \f(CW\*(C`$m\->path_info\*(C'\fR (the remainder of the top-level path) using Router::Simple routes. .PP It can be used whenever \f(CW\*(C`$m\->path_info\*(C'\fR is set, i.e. with a dhandler or with a partial path. .PP Use the \f(CW\*(C`route\*(C'\fR keyword to declare routes in a <%class> block. Like Router::Simple::connect, \f(CW\*(C`route\*(C'\fR takes a string/regex pattern and a destination hashref; the latter defaults to \f(CW\*(C`{}\*(C'\fR if omitted. e.g. .PP .Vb 5 \& <%class> \& route "wiki/:page", { action => "wiki" }; \& route "download/*.*", { action => "download" }; \& route "blog/{year:[0\-9]+}/{month:[0\-9]{2}}"; \& .Ve .PP This plugin overrides the default allow_path_info to return true for any component that declares at least one route. For components that do not declare a route, you will need to override \f(CW\*(C`allow_path_info\*(C'\fR as usual. .PP Any named captured arguments, including \f(CW\*(C`splat\*(C'\fR, are placed in component attributes, which are automatically declared (as standard read-write attributes) if you do not otherwise declare them. .PP If you specify more than one route in a component, they will be tried in turn, with the first matching route taking precedence. .PP If none of the routes match, the request will be declined; in a web context this generally means a 404. .PP e.g. Given the route declarations above in a component named '/site.mc', .IP "\(bu" 4 The \s-1URL\s0 \f(CW\*(C`/site/wiki/HomePage\*(C'\fR will set \f(CW\*(C`$.action = "wiki"\*(C'\fR and \f(CW\*(C`$.page = "HomePage"\*(C'\fR. .IP "\(bu" 4 The \s-1URL\s0 \f(CW\*(C`/site/download/ping.mp3\*(C'\fR will set \f(CW\*(C`$.action = "download"\*(C'\fR and \&\f(CW\*(C`$.splat = [\*(Aqping\*(Aq, \*(Aqmp3\*(Aq]\*(C'\fR. .IP "\(bu" 4 The \s-1URL\s0 \f(CW\*(C`/site/blog/2010/02\*(C'\fR will set \f(CW\*(C`$.year = "2010"\*(C'\fR and \f(CW\*(C`$.month = "02"\*(C'\fR. .IP "\(bu" 4 The URLs \f(CW\*(C`/site/other\*(C'\fR and \f(CW\*(C`/site/blog/10/02\*(C'\fR will result in a decline/404. .SH "SUPPORT" .IX Header "SUPPORT" The mailing list for Mason and Mason plugins is mason\-users@lists.sourceforge.net. You must be subscribed to send a message. To subscribe, visit . .PP You can also visit us at \f(CW\*(C`#mason\*(C'\fR on . .PP Bugs and feature requests will be tracked at \s-1RT:\s0 .PP .Vb 2 \& http://rt.cpan.org/NoAuth/Bugs.html?Dist=Mason\-Plugin\-RouterSimple \& bug\-mason\-plugin\-routersimple@rt.cpan.org .Ve .PP The latest source code can be browsed and fetched at: .PP .Vb 2 \& http://github.com/jonswar/perl\-mason\-plugin\-routersimple \& git clone git://github.com/jonswar/perl\-mason\-plugin\-routersimple.git .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" Mason, Router::Simple .SH "AUTHOR" .IX Header "AUTHOR" Jonathan Swartz .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2011 by Jonathan Swartz. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.