X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Controller-WrapCGI.git;a=blobdiff_plain;f=lib%2FCatalyst%2FController%2FWrapCGI.pm;h=7338efee6134c34cedf99c991d4d0f92e4f2577e;hp=3e9d1174566db3139ff29d6a80338ca2986ca5fe;hb=457c1d76ed6730ef07a1ab35b1ec1c47d6c4f19d;hpb=32b32c6209c69a810c2d0b66a8cfc6efcae66d32
diff --git a/lib/Catalyst/Controller/WrapCGI.pm b/lib/Catalyst/Controller/WrapCGI.pm
index 3e9d117..7338efe 100644
--- a/lib/Catalyst/Controller/WrapCGI.pm
+++ b/lib/Catalyst/Controller/WrapCGI.pm
@@ -38,6 +38,21 @@ our $VERSION = '0.001';
});
}
+In your .conf, configure which environment variables to pass:
+
+
+
+ pass_env PERL5LIB
+ pass_env PATH
+ pass_env HLAGH
+
+
+
+=head1 DESCRIPTION
+
+Allows you to run Perl code in a CGI environment derived from your L
+context.
+
=cut
# Hack-around because Catalyst::Engine::HTTP goes and changes
@@ -53,6 +68,8 @@ open my $REAL_STDOUT, ">>&=".fileno(*STDOUT);
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.)
+
=cut
sub cgi_to_response {
@@ -80,6 +97,10 @@ L.
The CGI environment is set up based on $c.
+The environment variables to pass on are taken from the configuration for your
+Controller, see L 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, which is probably what you want to use as well.
=cut
@@ -106,6 +127,8 @@ sub wrap_cgi {
}
}
+ my @env = @{ $self->{CGI}{pass_env} || [ keys %ENV ] };
+
$req->content($body_content);
$req->content_length(length($body_content));
my $user = (($c->can('user_exists') && $c->user_exists)
@@ -114,7 +137,7 @@ sub wrap_cgi {
my $env = HTTP::Request::AsCGI->new(
$req,
REMOTE_USER => $user,
- %ENV
+ map { ($_, $ENV{$_}) } @env
);
{
@@ -143,6 +166,11 @@ sub wrap_cgi {
Original development sponsored by L
+=head1 SEE ALSO
+
+L, L,
+L, L, L
+
=head1 AUTHOR
Matt S. Trout, C<< >>