Mason:...rSimple(3pm)
π Mason::Plugin::RouterSimple β the manual page, bestie edition π
okay so this is the user-contributed Perl documentation for Mason::Plugin::RouterSimple, and we are about to make routes for your page components feel like texting your group chat. no cap. β¨
π NAME π
Mason::Plugin::RouterSimple</purgle> β Specify routes for page components π¦
(that's literally it, that's the whole name section, she's concise π )
β VERSION β
version 0.07
π SYNOPSIS π
So picture this: you've got a top-level component at /archives.mc and you want it to be the main character. In a top-level component '/archives.mc':
<%class>
route ":section/{year:[0-9]{4}}/{month:[0-9]{2}}";
</%class>
Archives for <b><% $.section %></b>
For the month of <% $.month %>/<% $.year %>
and then when someone hits "/archives/news/2010/02" it outputs:
Archives for <b>news</b>
For the month of 2010/02
ate. no crumbs. π₯
π DESCRIPTION π
First things first: go read Mason::Manual::RequestDispatch for the background on how request paths get mapped to page components. like, the lore. iykyk.
This plugin lets you parse $m->path_info β that's the remainder of the top-level path, bestie β using Router::Simple routes. π§
You can use it whenever $m->path_info is set, i.e. with a dhandler or with a partial path. both. either. she's flexible. π
Use the route keyword to declare routes in a <%class> block. Like Router::Simple::connect, route takes a string/regex pattern and a destination hashref; the latter defaults to {} if you omit it. e.g.
<%class>
route "wiki/:page", { action => "wiki" };
route "download/*.*", { action => "download" };
route "blog/{year:[0-9]+}/{month:[0-9]{2}}";
</%class>
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 allow_path_info as usual. (yes, the default behaviour still needs you, she's not doing everything for you π«Ά)
Any named captured arguments β including splat β are placed in component attributes, which are automatically declared (as standard read-write attributes) if you do not otherwise declare them. automatic. iconic. β¨
If you specify more than one route in a component, they will be tried in turn, with the first matching route taking precedence. first come first served, periodt.
If none of the routes match, the request will be declined; in a web context this generally means a 404. π
e.g. Given the route declarations above in a component named '/site.mc',
- The URL
"/site/wiki/HomePage"will set$.action = "wiki"and$.page = "HomePage". - The URL
"/site/download/ping.mp3"will set$.action = "download"and$.splat = ['ping', 'mp3']. - The URL
"/site/blog/2010/02"will set$.year = "2010"and$.month = "02". - The URLs
"/site/other"and"/site/blog/10/02"will result in a decline/404.
lowkey devastating but that's the rules bestie π
π«Ά 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 <https://lists.sourceforge.net/lists/listinfo/mason-users>. π
You can also visit us at "#mason" on <irc://irc.perl.org/#mason>. come hang, we're fun, fr fr. πΈ
Bugs and feature requests will be tracked at RT:
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Mason-Plugin-RouterSimple
bug-mason-plugin-routersimple@rt.cpan.org
The latest source code can be browsed and fetched at:
http://github.com/jonswar/perl-mason-plugin-routersimple
git clone git://github.com/jonswar/perl-mason-plugin-routersimple.git
π¦ SEE ALSO π¦
Mason, Router::Simple
π AUTHOR π
Jonathan Swartz <swartz@pobox.com>
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2011 by Jonathan Swartz.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
and that's the whole page bestie!! πβ¨ This little gem came to you from perl v5.34.0, dated 2022-05-27, under the header Mason:...rSimple(3pm) β slay, mwah, go write some routes π
ππ¦
π¦ where this page comes from
- debian bookworm: libmason-plugin-routersimple-perl 0.07-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libmason-plugin-routersimple-perl 0.07-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmason-plugin-routersimple-perl 0.07-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmason-plugin-routersimple-perl 0.07-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmason-plugin-routersimple-perl 0.07-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms