NAME
Catalyst::Controller::WrapCGI - Run CGIs in Catalyst
VERSION
Version 0.002
SYNOPSIS
package MyApp::Controller::Foo;
use parent qw/Catalyst::Controller::WrapCGI/;
sub hello : Path('cgi-bin/hello.cgi') {
my ($self, $c) = @_;
$self->cgi_to_response($c, sub {
use CGI ':standard';
print header, start_html('Hello'),
h1('Catalyst Rocks!'),
end_html;
});
}
In your .conf, configure which environment variables to pass:
<Controller::Foo>
<CGI>
username_field username # used for REMOTE_USER env var
pass_env PERL5LIB
pass_env PATH
pass_env /^MYAPP_/
</CGI>
</Controller::Foo>
DESCRIPTION
Allows you to run Perl code in a CGI environment derived from your Catalyst context.
If you just want to run CGIs from files, see Catalyst::Controller::CGIBin.
CONFIGURATION
$your_controller-
{CGI}{pass_env}> should be an array of environment variables or regular expressions to pass through to your CGIs. Entries surrounded by /
characters are considered regular expressions.
Default is to pass the whole of %ENV
.
{CGI}{username_field}
should be the field for your user's name, which will be read from $c-
user->obj>. Defaults to 'username'.
See "SYNOPSIS" for an example.
METHODS
$self->cgi_to_response($c, $coderef)
Does the magic of running $coderef in a CGI environment, and populating the appropriate parts of your Catalyst context with the results.
Calls wrap_cgi (below.)
$self->wrap_cgi($c, $coderef)
Runs $coderef in a CGI environment using HTTP::Request::AsCGI, returns an HTTP::Response.
The CGI environment is set up based on $c.
The environment variables to pass on are taken from the configuration for your Controller, see "SYNOPSIS" for an example. If you don't supply a list of environment variables to pass, the whole of %ENV is used.
Used by cgi_to_response (above), which is probably what you want to use as well.
ACKNOWLEDGEMENTS
Original development sponsored by http://www.altinity.com/
SEE ALSO
Catalyst::Controller::CGIBin, CatalystX::GlobalContext, Catalyst::Controller, CGI, Catalyst
AUTHOR
Matt S. Trout, <mst at shadowcat.co.uk>
BUGS
Please report any bugs or feature requests to bug-catalyst-controller-wrapcgi at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Catalyst-Controller-WrapCGI. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
More information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Catalyst-Controller-WrapCGI
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
COPYRIGHT & LICENSE
Copyright (c) 2008 Matt S. Trout
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.