The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


CGI::Application::Dispatch::PSGI - PSGI adapter for CGI::Application::Dispatch


CGI::Application::Dispatch is a (not so) simple dispatcher for families of CGI::Application-based applications served under common URL base.

It is a little too high-level to be directly converted to PSGI with CGI::Application::PSGI so the need for a special adapter rose. Here it is.

    ### in your dispatch.psgi:
    use Your::Application::Dispatch;
    use CGI::Application::Dispatch::PSGI;


Most of CGI::Application::Dispatch scripts may be converted by simply changing dispatch() method call to as_psgi() call.

The code is a mere mashup of CGI::Application::PSGI and CGI::Application::Emulate::PSGI, so all the good parts here are courtesy of their respective authors but the bugs are all mine.


When you "use" this package it installs a single additional method as_psgi into CGI::Application::Dispatch which is immediately available to your custom dispatcher class through inheritance.


This is a constructor for PSGI application sub. It must be called as a method and takes an optional hash with arguments for dispatcher. For additional information about the arguments, see "dispatch(%args)" in CGI::Application::Dispatch.


    my $app = MyApp::CAP::Dispatch->as_psgi(
        args_to_new => {
            PARAMS => {
                cfg_file => "$cfgdir/myapp.cfg",


Alex Kapranoff, <kappa at>


CGI::Application::Dispatch::PSGI was NOT tested under mod_perl. Patches (if need arises) are welcome.

This module was made to use Plack's middlewares during debugging and was never run in production. CGI::Application::Dispatch should really rely less on %ENV.

Please report any bugs or feature requests to bug-cgi-application-dispatch-psgi at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


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

    perldoc CGI::Application::Dispatch::PSGI

You can also look for information at:

SEE ALSO, CGI::Application::PSGI, CGI::Application::Emulate::PSGI, CGI::Application::Dispatch::Server.


Copyright 2009 Alex Kapranoff.

This program is released under the following license: GPLv3