From: Matt S Trout Date: Tue, 11 May 2010 23:18:09 +0000 (+0100) Subject: experimentally expose psgi $env as $_[ENV] X-Git-Tag: v0.003~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FWeb-Simple.git;a=commitdiff_plain;h=with-ENV experimentally expose psgi $env as $_[ENV] --- diff --git a/Changes b/Changes index b870a16..64df5fa 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,6 @@ Change log for Web::Simple - + - Experimentally use $_[ENV] for the PSGI env - Add CSS::Declare - Add more tags to HTML::Tags diff --git a/lib/Web/Simple.pm b/lib/Web/Simple.pm index a9711fe..2cc4ae2 100644 --- a/lib/Web/Simple.pm +++ b/lib/Web/Simple.pm @@ -45,6 +45,7 @@ sub _export_into { *{"${app_package}::default_config"} = sub { $app_package->_setup_default_config(@_); }; + *{"${app_package}::ENV"} = sub () { -1 }; *{"${app_package}::self"} = \${"${app_package}::self"}; require Web::Simple::Application; unshift(@{"${app_package}::ISA"}, 'Web::Simple::Application'); diff --git a/lib/Web/Simple/Application.pm b/lib/Web/Simple/Application.pm index c24ac79..be34500 100644 --- a/lib/Web/Simple/Application.pm +++ b/lib/Web/Simple/Application.pm @@ -27,7 +27,7 @@ use warnings FATAL => 'all'; my ($self, $env, @args) = @_; my $next = $self->_has_match ? $self->next : undef; if (my ($env_delta, @match) = $self->_match_against($env)) { - if (my ($result) = $self->_execute_with(@args, @match)) { + if (my ($result) = $self->_execute_with(@args, @match, $env)) { if ($self->_is_dispatcher($result)) { $next = $result->set_next($next); $env = { %$env, %$env_delta }; @@ -191,7 +191,7 @@ sub _build_dispatcher_from_spec { my $matcher = ( defined($proto) && length($proto) ? $parser->parse_dispatch_specification($proto) - : undef + : sub { ({}, $_[1]) } ); return $class->_build_dispatcher({ match => $matcher,