Catalyst::Middleware::Stash - The Catalyst stash - in middleware
We've moved the Catalyst stash to middleware. Please don't use this directly since it is likely to move off the Catalyst namespace into a stand alone distribution
We store a coderef under the PSGI_KEY which can be dereferenced with key values or nothing to access the underly hashref.
PSGI_KEY
This class defines the following subroutines.
Returns the hash key where we store the stash. You should not assume the string value here will never change! Also, its better to use "get_stash" or "stash".
Expect: $psgi_env.
Exportable subroutine.
Get the stash out of the $env.
$env
Expects: An object that does env and arguments
env
Given an object with a method env get or set stash values, either as a method or via hashref modification. This stash is automatically reset for each request (it is not persistent or shared across connected clients. Stash key / value are stored in memory.
use Plack::Request; use Catalyst::Middleware::Stash 'stash'; my $app = sub { my $env = shift; my $req = Plack::Request->new($env); my $stashed = $req->stash->{in_the_stash}; # Assume the stash was previously populated. return [200, ['Content-Type' => 'text/plain'], ["I found $stashed in the stash!"]]; };
If the stash does not yet exist, we initialize one and return that.
This class defines the following methods.
Used by plack to call the middleware
To install Catalyst::Runtime, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::Runtime
CPAN shell
perl -MCPAN -e shell install Catalyst::Runtime
For more information on module installation, please visit the detailed CPAN module installation guide.