[cgiapp] testing the new CAD::PSGI version

Mark Stosberg mark at summersault.com
Mon May 16 08:34:54 EDT 2011


> CGI::Application::Dispatch::PSGI gives any CGI script using CGI::App
> access to PSGI's amazing capabilities. It's what I use for every CGI
> script, nowadays.

Ron,

Could you test the Github version of CAD::PSGI if you haven't already?
As part of re-implementing it better, it should be a little faster, and
the calling syntax did have to change slightly.

Before:

 use Your::Application::Dispatch;
 use CGI::Application::Dispatch::PSGI;
 Your::Application::Dispatch->as_psgi;

After:

 use Your::Application::Dispatch;
 Your::Application::Dispatch->as_psgi;

 ### In Your::Application::Dispatch;
 package Your::Application::Dispatch;
 use base 'CGI::Application::Dispatch::PSGI';


The full Synopsis is below. Here's the the link to the source:

https://github.com/markstos/CGI--Application--Dispatch/blob/psgi-support/lib/CGI/Application/Dispatch/PSGI.pm

The current maintainer of that namespace has give me authority to upload
this replacement version there, which has a more efficient implementation.


######

=head1 SYNOPSIS

=head2 Out of Box

Under mod_perl:

  # change "Apache1" to "Apache2" as needed.

  <Location />
  SetHandler perl-script
  PerlHandler Plack::Handler::Apache1
  PerlSetVar psgi_app /path/to/app.psgi
  </Location>

  <Perl>
  use Plack::Handler::Apache1;
  Plack::Handler::Apache1->preload("/path/to/app.psgi");
  </Perl>

Under CGI:

This would be the instance script for your application, such
as /cgi-bin/dispatch.cgi:

    ### in your dispatch.psgi:
    # ( in a persistent environment, use FindBin::Real instead. )
    use FindBin 'Bin';
    use lib "$Bin/../perllib';
    use Your::Application::Dispatch;
    Your::Application::Dispatch->as_psgi;

    ### In Your::Application::Dispatch;
    package Your::Application::Dispatch;
    use base 'CGI::Application::Dispatch::PSGI';


=head2 With a dispatch table

    package MyApp::Dispatch;
    use base 'CGI::Application::Dispatch::PSGI';

    sub dispatch_args {
        return {
            prefix  => 'MyApp',
            table   => [
                ''                => { app => 'Welcome', rm => 'start' },
                ':app/:rm'        => { },
                'admin/:app/:rm'  => { prefix   => 'MyApp::Admin' },
            ],
        };
    }



More information about the cgiapp mailing list