Cataly...::Stash(3pm)
π Catalyst::Middleware::Stash β the Catalyst stash, but make it middleware π
okay bestie, so this is Catalyst::Middleware::Stash, a lil Perl module, and it lives in the User Contributed Perl Documentation section of the manual (that's the 3pm part, iykyk). Buckle up, it's short but it's important.
β¨ NAME β¨
Catalyst::Middleware::Stash β the Catalyst stash, except it's in middleware now. slay. π
πΈ DESCRIPTION πΈ
So here's the tea: we moved the Catalyst stash into middleware. π
Please do NOT use this directly, because it is likely to move off the Catalyst namespace into a stand alone distribution. it's giving "temporary housing situation". π
We store a coderef under the PSGI_KEY which can be dereferenced with key values β or with nothing β to access the underlying hashref. cute, right?
Anything you place into the stash will be available in the stash of any 'mounted' Catalyst applications. A mounted Catalyst application may set the stash and 'pass back' information to the parent application. And non-Catalyst applications can use this middleware to access and set stash values too. equal opportunity stash access, we love to see it. π«Ά
Please note: I highly recommend having a stronger interface than a stash key between applications. fr fr. a stash key is not a personality, it's not an API contract. π
And for more information? the current test case t/middleware-stash.t is the best documentation. iconic behavior honestly. that's the real manual. πβ¨
π¦ SUBROUTINES π¦
This class defines the following subroutines. let's goooo.
π PSGI_KEY
Returns the hash key where we store the stash.
You should NOT assume the string value here will never change! it can change, bestie, don't build your whole life on it. π€
Also, it's better to use get_stash or stash. those are the good ones. π
π get_stash
Expect: $psgi_env.
Exportable subroutine.
Get the stash out of the $env. that's it, that's the whole job. β¨
π stash
Expects: An object that does env and arguments.
Exportable subroutine.
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, an exception is thrown. no stash? no vibes. exception. π
π METHODS π
This class defines the following methods.
π§ call
Used by plack to call the middleware. that's the whole description. short king. π
okay that's the whole page bestie, we ate and left no crumbs π
this was brought to you by perl v5.40.0, dated 2024-11-15, and yeah the header/footer both say Cataly...::Stash(3pm) because the terminal clipped it like it clips my dreams. π byeeee π¦ππ
π¦ where this page comes from
- debian trixie: libcatalyst-perl 5.90132-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcatalyst-perl 5.90132-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcatalyst-perl 5.90132-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms