Subject: | new psgi env interface in Catalyst / Plack |
Hey,
Thank you for this plugin. I would like to use it, but my 'new'
installation of Catalyst / Plack need a different interface to the psgi
session environment.
attached, the patch,
thx,k
Subject: | fixes_psgi_env.patch |
diff --git a/lib/Catalyst/Plugin/Session/PSGI.pm b/lib/Catalyst/Plugin/Session/PSGI.pm
index 1c804e3..9d188aa 100644
--- a/lib/Catalyst/Plugin/Session/PSGI.pm
+++ b/lib/Catalyst/Plugin/Session/PSGI.pm
@@ -2,6 +2,19 @@ package Catalyst::Plugin::Session::PSGI;
use strict;
use warnings;
+=head2 _psgi_env
+
+Fetches the psgi env globally from the request env
+
+=cut
+
+sub _psgi_env {
+ my ( $c ) = @_;
+
+ return $c->request->can('env') ? $c->request->env : $c->request->{_psgi_env};
+}
+
+
=head1 EXPERIMENTAL
This distribution should be considered B<experimental>. Although functional, it
diff --git a/lib/Catalyst/Plugin/Session/State/PSGI.pm b/lib/Catalyst/Plugin/Session/State/PSGI.pm
index adfdd03..f51443d 100644
--- a/lib/Catalyst/Plugin/Session/State/PSGI.pm
+++ b/lib/Catalyst/Plugin/Session/State/PSGI.pm
@@ -2,6 +2,8 @@ package Catalyst::Plugin::Session::State::PSGI;
use strict;
use warnings;
+use Catalyst::Plugin::Session::PSGI;
+
=head1 EXPERIMENTAL
This distribution should be considered B<experimental>. Although functional, it
@@ -11,6 +13,7 @@ may break in currently undiscovered use cases.
use base qw/Catalyst::Plugin::Session::State/;
+
=head1 SYNOPSIS
use Catalyst qw/
@@ -54,7 +57,7 @@ This method retrieves the session-id from the PSGI/Plack environment information
=cut
sub get_session_id {
my $c = shift;
- my $psgi_env = $c->request->{_psgi_env};
+ my $psgi_env = Catalyst::Plugin::Session::PSGI::_psgi_env($c);
return
unless defined $psgi_env;
diff --git a/lib/Catalyst/Plugin/Session/Store/PSGI.pm b/lib/Catalyst/Plugin/Session/Store/PSGI.pm
index 3955d6b..b9971a0 100644
--- a/lib/Catalyst/Plugin/Session/Store/PSGI.pm
+++ b/lib/Catalyst/Plugin/Session/Store/PSGI.pm
@@ -2,6 +2,8 @@ package Catalyst::Plugin::Session::Store::PSGI;
use strict;
use warnings;
+use Catalyst::Plugin::Session::PSGI;
+
=head1 EXPERIMENTAL
This distribution should be considered B<experimental>. Although functional, it
@@ -40,7 +42,7 @@ sub get_session_data {
my ($c, $id) = @_;
# grab the PSGI environment
- my $psgi_env = $c->request->{_psgi_env};
+ my $psgi_env = Catalyst::Plugin::Session::PSGI::_psgi_env($c);
return
unless defined $psgi_env;
@@ -63,7 +65,7 @@ sub store_session_data {
my ($c, $id, $data) = @_;
# grab the PSGI environment
- my $psgi_env = $c->request->{_psgi_env};
+ my $psgi_env = Catalyst::Plugin::Session::PSGI::_psgi_env($c);
return
unless defined $psgi_env;