rename ENV to PSGI_ENV (*ENV is forced into main::)
[catagits/Web-Simple.git] / lib / Web / Simple.pm
index a9711fe..80c1f47 100644 (file)
@@ -45,6 +45,7 @@ sub _export_into {
     *{"${app_package}::default_config"} = sub {
       $app_package->_setup_default_config(@_);
     };
+    *{"${app_package}::PSGI_ENV"} = sub () { -1 };
     *{"${app_package}::self"} = \${"${app_package}::self"};
     require Web::Simple::Application;
     unshift(@{"${app_package}::ISA"}, 'Web::Simple::Application');
@@ -489,6 +490,16 @@ from subroutine prototypes, so this is equivalent to
 
   sub (GET+/user/*) {
 
+=head3 Accessing the PSGI env hash
+
+To gain the benefit of using some middleware, specifically
+Plack::Middleware::Session access to the ENV hash is needed. This is provided
+in arguments to the dispatched handler. You can access this hash with the
+exported +ENV constant.
+
+    sub (GET + /foo + ?some_param=) {
+        my($self, $some_param, $env) = @_[0, 1, +ENV];
+
 =head1 EXPORTED SUBROUTINES
 
 =head2 default_config