[cgiapp] RFC: first-class support for PSGI in CGI::Application
Ron Savage
ron at savage.net.au
Tue Mar 2 17:15:42 EST 2010
Hi Mark
On Thu, 2010-02-18 at 12:58 -0500, Mark Stosberg wrote:
> 1. Passing in and setting up the PSGI env
> 2. Returning the PSGI required return format
> 3. Accessing the environment in an abstracted way.
Here's how I access the environment in CGI::App-based code:
sub script_name
{
my($self) = @_;
my($env);
my($script_name);
# Are we running under Plack?
if ($env = $self -> query -> can('env') )
{
# Yes.
$env = $self -> query -> env;
$script_name = $$env{SCRIPT_NAME};
}
else
{
# No.
$script_name = $ENV{SCRIPT_NAME};
}
$self -> log(debug => "Script name: $script_name");
return $script_name;
} # End of script_name.
Of course, other users might prefer to return the whole env.
I'd like to see this concept integrated into the underlying code.
The problem is not really how to do it. The problem is using or shipping
code which might have to run under Apache (say).
That is, we can't guarantee that the end user of the code will use
Plack, so we need something independent of the server.
--
Ron Savage
ron at savage.net.au
http://savage.net.au/index.html
More information about the cgiapp
mailing list