CGI::Snapp::Dispatch::Regexp - Dispatch requests to CGI::Snapp-based objects
Note the call to new()!
use CGI::Snapp::Dispatch::Regexp; CGI::Snapp::Dispatch::Regexp -> new -> dispatch ( prefix => 'MyApp', table => [ qr|/([^/]+)/?| => { names => ['app'] }, qr|/([^/]+)/([^/]+)/?| => { names => [qw(app rm)] }, qr|/([^/]+)/([^/]+)/page(\d+)\.html?| => { names => [qw(app rm page)] }, ], );
This would also work in a PSGI context. Note the call to new()!
CGI::Snapp::Dispatch::Regexp -> new -> as_psgi ( ... );
See t/psgi.regexp.t and t/regexp.t.
This usage of new(), so unlike CGI::Application::Dispatch, is dicussed in "PSGI Scripts" in CGI::Snapp::Dispatch.
CGI::Snapp::Dispatch::Regexp is a sub-class of CGI::Snapp::Dispatch which overrides 2 methods:
The point is to allow you to use regexps as rules to match the path info, whereas CGI::Snapp::Dispatch always assumes your rules are strings.
See "Description" in CGI::Snapp::Dispatch for more detail.
This module is available as a Unix-style distro (*.tgz).
See http://savage.net.au/Perl-modules/html/installing-a-module.html for help on unpacking and installing distros.
Install CGI::Snapp::Dispatch as you would for any Perl module:
Perl
Run:
cpanm CGI::Snapp::Dispatch
or run:
sudo cpan CGI::Snapp::Dispatch
or unpack the distro, and then either:
perl Build.PL ./Build ./Build test sudo ./Build install
or:
perl Makefile.PL make (or dmake or nmake) make test make install
new() is called as my($app) = CGI::Snapp::Dispatch::Regexp -> new(k1 => v1, k2 => v2, ...).
new()
my($app) = CGI::Snapp::Dispatch::Regexp -> new(k1 => v1, k2 => v2, ...)
It returns a new object of type CGI::Snapp::Dispatch::Regexp.
CGI::Snapp::Dispatch::Regexp
This module accepts exactly the same parameters as does CGI::Snapp::Dispatch.
See "Constructor and Initialization" in CGI::Snapp::Dispatch for details.
Returns a hashref of args to be used by "dispatch(@args)" in CGI::Snapp::Dispatch or "as_psgi(@args)" in CGI::Snapp::Dispatch.
Default output:
{ args_to_new => {}, default => '', prefix => '', table => [ qr|/([^/]+)/?| => {names => ['app']}, qr|/([^/]+)/([^/]+)/?| => {names => [qw/app rm/]}, ], };
The differences between this structure and what's used by CGI::Snapp::Dispatch are discussed in the "FAQ".
Yes. See t/psgi.regexp.t and t/regexp.t.
This module works with both "dispatch(@args)" in CGI::Snapp::Dispatch and "as_psgi(@args)" in CGI::Snapp::Dispatch.
Basically it's the same as in "What is the structure of the dispatch table?" in CGI::Snapp::Dispatch.
The important difference is in the table key, which can be seen just above, under "dispatch_args($args)".
The pairs of elements in the table, compared to what's handled by CGI::Snapp::Dispatch are:
See the "Synopsis" for a more complex example.
See "Troubleshooting" in CGI::Snapp::Dispatch.
The file CHANGES was converted into Changelog.ini by Module::Metadata::Changes.
Version numbers < 1.00 represent development versions. From 1.00 up, they are production versions.
See "COPYRIGHT & LICENSE" in CGI::Application::Dispatch::Regexp. This module is a fork of that code.
Email the author, or log a bug on RT:
https://rt.cpan.org/Public/Dist/Display.html?Name=CGI::Snapp::Dispatch.
CGI::Snapp::Dispatch was written by Ron Savage <ron@savage.net.au> in 2012.
Home page: http://savage.net.au/index.html.
Australian copyright (c) 2012, Ron Savage.
All Programs of mine are 'OSI Certified Open Source Software'; you can redistribute them and/or modify them under the terms of The Artistic License, a copy of which is available at: http://www.opensource.org/licenses/index.html
To install CGI::Snapp::Dispatch, copy and paste the appropriate command in to your terminal.
cpanm
CPAN shell
perl -MCPAN -e shell install CGI::Snapp::Dispatch
For more information on module installation, please visit the detailed CPAN module installation guide.