GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
REST::Application::Routes(3) User Contributed Perl Documentation REST::Application::Routes(3)

REST::Application::Routes - An implementation of Ruby on Rails type routes.

    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"

Ruby on Rails has this concept of routes. Routes are URI path info templates which are tied to specific code (i.e. Controllers and Actions in Rails). That is 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.

A template is of the form: "/foo/:variable/bar" where variables are always prefaced with a colon. When a given path is 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) and the values are what was specified in place of the variables.

The route map is ordered, so the most specific matching template is used and so you should order your templates from least generic to most generic.

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.

These are methods which REST::Application::Routes has but its superclass does not.

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.

This is an alias for "getLastMatchPattern()", since this class is about templates rather than regexes.

Matthew O'Connor <matthew@canonical.org>

This program is free software. It is subject to the same license as Perl itself.

REST::Application, <http://manuals.rubyonrails.com/read/chapter/65>
2007-08-09 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.