Adding some additional docs and VERSION, AUTHORITY stuff
[catagits/Web-Session.git] / lib / Plack / Middleware / Session.pm
index aff0685..03f8798 100644 (file)
@@ -2,6 +2,9 @@ package Plack::Middleware::Session;
 use strict;
 use warnings;
 
+our $VERSION   = '0.01';
+our $AUTHORITY = 'cpan:STEVAN';
+
 use Plack::Session;
 use Plack::Request;
 use Plack::Response;
@@ -10,12 +13,17 @@ use Scalar::Util;
 
 use parent 'Plack::Middleware';
 
-use Plack::Util::Accessor qw( state store );
+use Plack::Util::Accessor qw(
+    state
+    store
+    session_class
+);
 
 sub prepare_app {
     my $self = shift;
 
-    $self->state('Cookie') unless $self->state;
+    $self->session_class( 'Plack::Session' ) unless $self->session_class;
+    $self->state( 'Cookie' )                 unless $self->state;
 
     $self->state( $self->inflate_backend('Plack::Session::State', $self->state) );
     $self->store( $self->inflate_backend('Plack::Session::Store', $self->store) );
@@ -37,7 +45,7 @@ sub call {
     my $self = shift;
     my $env  = shift;
 
-    $env->{'plack.session'} = Plack::Session->new(
+    $env->{'plack.session'} = $self->session_class->new(
         state   => $self->state,
         store   => $self->store,
         request => Plack::Request->new( $env )
@@ -131,6 +139,37 @@ you can use this noop module.
 
 =back
 
+=head1 OPTIONS
+
+The following are options that can be passed to this mdoule.
+
+=over 4
+
+=item I<state>
+
+This is expected to be an instance of L<Plack::Session::State> or an
+object that implements the same interface. If no option is provided
+the default L<Plack::Session::State::Cookie> will be used.
+
+=item I<store>
+
+This is expected to be an instance of L<Plack::Session::Store> or an
+object that implements the same interface. If no option is provided
+the default L<Plack::Session::Store> will be used.
+
+It should be noted that this default is an in-memory volatile store
+is only suitable for development (or single process servers). For a
+more robust solution see L<Plack::Session::Store::File> or
+L<Plack::Session::Store::Cache>.
+
+=item I<session_class>
+
+This can be used to override the actual session class. It currently
+defaults to L<Plack::Session> but you can substitute any class which
+implements the same interface.
+
+=back
+
 =head1 BUGS
 
 All complex software has bugs lurking in it, and this module is no