CGI::Application::Emulate::PSGI - a legacy-code-friendly PSGI adapter for CGI::Application
Create a PSGI application from a CGI::Application project:
# if using CGI::Application my $psgi_app = CGI::Application::Emulate::PSGI->handler(sub { my $webapp = WebApp->new(); $webapp->run(); }); # if using CGI::Application::Dispatch my $psgi_app = CGI::Application::Emulate::PSGI->handler(sub { WebApp::Dispatch->dispatch(); });
See plackup for options for running a PSGI application.
CGI::Application::Emulate::PSGI allows a project based on CGI::Application to run as a PSGI application. Differences from CGI::Application::PSGI are:
CGI::Application::PSGI (that uses CGI::PSGI) does not support programs calling CGI.pm in func-style (like CGI::virtual_host()). CGI::Application::Emulate::PSGI sets up environment variables so that code using CGI.pm will work. Both approaches explictly use CGI.pm as the query object.
The interface of CGI::Application::Emulate::PSGI is different from CGI::Application::PSGI, and is compatible with CGI::Application::Dispatch.
This difference is in favor of CGI::Application::PSGI, which more directly generates the HTTP headers in PSGI format. This module requires additional processing: First CGI::Application builds the full response including the headers and body, then we parse the final result back into the header and body format called for by the PSGI spec.
Kazuho Oku <kazuhooku@gmail.com>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
CGI::Application::PSGI, CGI
To install CGI::Application::Emulate::PSGI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CGI::Application::Emulate::PSGI
CPAN shell
perl -MCPAN -e shell install CGI::Application::Emulate::PSGI
For more information on module installation, please visit the detailed CPAN module installation guide.