experimentally expose psgi $env as $_[ENV] with-ENV
Matt S Trout [Tue, 11 May 2010 23:18:09 +0000 (00:18 +0100)]
Changes
lib/Web/Simple.pm
lib/Web/Simple/Application.pm

diff --git a/Changes b/Changes
index b870a16..64df5fa 100644 (file)
--- 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
 
index a9711fe..2cc4ae2 100644 (file)
@@ -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');
index c24ac79..be34500 100644 (file)
@@ -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,