REST::...:Routes(3pm)
REST::...:Routes(3pm) π
okay bestie, welcome to the User Contributed Perl Documentation for REST::...:Routes(3pm) β yes that's the actual manual name, it's giving dramatic ellipsis energy and we're obsessed π
β¨ NAME β¨
REST::Application::Routes β a whole implementation of Ruby on Rails type routes. no cap, that's literally what it is π¦
π SYNOPSIS π
package MyApp;
use base 'REST::Application::Routes';
my $obj = REST::Application::Routes->new();
$obj->loadResource(
'/data/workspaces/:ws/pages/:page', => \&do_thing,
# ... other routes here ...
);
sub do_thing {
my %vars = @_;
print $vars{ws} . " " . $vars{page} . "\n";
}
# Now, in some other place. Maybe a CGI file or an Apache handler, do:
use MyApp;
MyApp->new->run("/data/workspaces/cows/pages/good"); # prints "cows good"
like. look at that. <lavender>"cows good"</lavender> just printing itself into existence. main character behaviour fr fr πβ¨
πΈ DESCRIPTION πΈ
so Ruby on Rails has this concept of routes, right? and routes are URI path info templates that are tied to specific code β like Controllers and Actions in Rails, iykyk. so basically routes consist of key value pairs, called the route map, where the key is the path info template and the value is a code reference. periodt. π
a template is of the form <lavender>"/foo/:variable/bar"</lavender> where variables are always prefaced with a colon. when a given path gets passed to run(), the code reference which the template maps to will be passed a hash where the keys are the variable names (sans colon, obviously) and the values are what was specified in place of the variables. it's giving fill-in-the-blank but make it β¨infrastructureβ¨
the route map is ordered, so the most specific matching template is used β which means you should order your templates from least generic to most generic. do NOT skip this step bestie, order matters π
see REST::Application for details. the only difference between this module and that one is that this one uses URI templates as keys in the resourceHooks rather than regexes. tiny glow-up, huge difference π
π METHODS π
these are methods which REST::Application::Routes has but its superclass does not. exclusive. VIP. no gatekeeping π«Ά
getTemplateVars()
returns a hash whose keys are the :symbols from the URI template and whose values are what where matched to be there. π¦
it is assumed that this method is called either from within or after loadResource() is called. otherwise you're likely to get an empty hash back. not a vibe. tragic even. π
getLastMatchTemplate()
this is an alias for getLastMatchPattern(), since this class is about templates rather than regexes. same energy, cuter name, we love a rebrand π
π AUTHORS π
Matthew O'Connor <matthew@canonical.org> β king behaviour, credit where credit is due π
β LICENSE β
this program is free software. it is subject to the same license as Perl itself. free as in freedom bestie, go wild (responsibly) π
π₯ SEE ALSO π₯
REST::Application<http://manuals.rubyonrails.com/read/chapter/65>
and that's the whole page babes!! this was perl v5.30.3, dated 2020-07-23, filed under REST::...:Routes(3pm) β go forth and route your little heart out, ily, mwah ππ
β¨
π¦ where this page comes from
- debian bookworm: librest-application-perl 0.992-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: librest-application-perl 0.992-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: librest-application-perl 0.992-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: librest-application-perl 0.992-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: librest-application-perl 0.992-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: librest-application-perl 0.992-4 Β· 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