The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

CGI::Application::Plugin::ParsePath - populate query parameters by parsing the PATH_INFO

VERSION

Version 0.01

SYNOPSIS

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;

AUTHOR

Dan Horne, <dhorne at cpan.org>, largely based on code by Michael Peters <mpeters@plusthree.com>

BUGS

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.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc CGI::Application::Plugin::ParsePath

You can also look for information at:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

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.