Commit | Line | Data |
6561feae |
1 | package ## Hide from pause |
2 | Catalyst::Middleware::Stash; |
3 | |
4 | # Please don't use this, this is likely to go away before stable version is |
5 | # released. Ideally this could be a stand alone distribution. |
6 | # |
7 | |
8 | use strict; |
9 | use warnings; |
10 | use base 'Plack::Middleware'; |
11 | |
12 | sub PSGI_KEY { 'Catalyst.Stash.v1' }; |
13 | |
14 | sub _init_stash { |
15 | my ($self, $env) = @_; |
16 | $env->{&PSGI_KEY} = bless +{}, 'Catalyst::Stash'; |
17 | } |
18 | |
19 | sub get { |
20 | my ($class, $env) = @_; |
21 | return $env->{&PSGI_KEY}; |
22 | } |
23 | |
24 | sub call { |
25 | my ($self, $env) = @_; |
26 | $self->_init_stash($env); |
27 | return $self->app->($env); |
28 | } |
29 | |
30 | =head1 TITLE |
31 | |
32 | Catalyst::Middleware::Stash - The Catalyst stash - in middleware |
33 | |
34 | =head1 DESCRIPTION |
35 | |
36 | We've moved the L<Catalyst> stash to middleware. Please don't use this |
37 | directly since it is likely to move off the Catalyst namespace into a stand |
38 | alone distribution |
39 | |
40 | =head1 METHODS |
41 | |
42 | This class defines the following methods |
43 | |
44 | =head2 PSGI_KEY |
45 | |
46 | Returns the hash key where we store the stash |
47 | |
48 | =head2 get |
49 | |
50 | Get the stash out of the C<$env> |
51 | |
52 | =head2 call |
53 | |
54 | Used by plack to call the middleware |
55 | |
56 | =cut |
57 | |
58 | 1; |