CGI::Application::Plugin::ParsePath - populate query parameters by parsing the PATH_INFO
Version 0.01
This module populates the CGI query parameters based on the query path. It shamelessly steals the PATH_INFO parsing method from Michael Peters' CGI::Application::Dispatch.
Because the query parameters rather than the application parameters are populated, modules like CGI::Application::Plugin::ValidateRM are supported.
In your webapp.pl instance script:
use My::Blog; # Supply a table that specifies rules for parsing the PATH. # Basically, we loop through each line stopping at the first rule # that matches. Path element definitions that preceded by colons # populate CGI query parameters with the same name. In the case # where an element name is followed by a question mark, the # parameter is optional. my $webapp = My::Blog->new( PARAMS => { 'table' => = [ '' => {rm => 'recent'}, 'posts/:category' => {rm => 'posts' }, 'date/:year/:month?/:day?' => { rm => 'by_date', }, '/:rm/:id' => { }, ]; } ); $webapp->run(); # Examples # QUERY PATH: webapp.pl/ # QUERY PARAMS: rm = recent # QUERY PATH: webapp.pl/posts/3 # QUERY PARAMS: rm = posts, category = 3 # QUERY PATH: webapp.pl/date/2004/12/02 # QUERY PARAMS: rm = by_date, year = 2004, month = 12, day = 02 # QUERY PATH: webapp.pl/edit/1234 # QUERY PARAMS: rm = edit, id = 1234
In your application module simply include the plugin:
use CGI::Application::Plugin::ParsePath;
Dan Horne, <dhorne at cpan.org>, largely based on code by Michael Peters <mpeters@plusthree.com>
<dhorne at cpan.org>
<mpeters@plusthree.com>
Please report any bugs or feature requests to bug-cgi-application-plugin-parsepath at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CGI-Application-Plugin-ParsePath. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-cgi-application-plugin-parsepath at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc CGI::Application::Plugin::ParsePath
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/CGI-Application-Plugin-ParsePath
CPAN Ratings
http://cpanratings.perl.org/d/CGI-Application-Plugin-ParsePath
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=CGI-Application-Plugin-ParsePath
Search CPAN
http://search.cpan.org/dist/CGI-Application-Plugin-ParsePath
Copyright 2007 Michael Peters & Dan Horne, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install CGI::Application::Plugin::ParsePath, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CGI::Application::Plugin::ParsePath
CPAN shell
perl -MCPAN -e shell install CGI::Application::Plugin::ParsePath
For more information on module installation, please visit the detailed CPAN module installation guide.