Plack::...cursive(3)
π NAME π
Plack::Middleware::Recursive β bestie, this one lets your PSGI apps include or forward requests recursively, no cap πβ¨
π SYNOPSIS π
Okay so first up, with Builder:
# with Builder
enable "Recursive";
And then inside your apps:
# in apps
my $res = $env->{'plack.recursive.include'}->("/new_path");
Or, if you wanna go the dramatic route and use exceptions:
# Or, use exceptions
my $app = sub {
# ...
Plack::Recursive::ForwardRequest->throw("/new_path");
};
She's giving options, she's giving versatility π
β¨ DESCRIPTION β¨
Plack::Middleware::Recursive lets PSGI applications recursively include or forward requests to other paths. Iconic behaviour fr fr.
So here's the tea: applications can make use of callbacks stored in $env->{'plack.recursive.include'} to include another path and get the response back β whether that's an array ref or a code ref depends on your application, so like, know your own app bestie π«Ά
OR β and this is the fun part β you can throw an exception Plack::Recursive::ForwardRequest literally anywhere in the code to forward the current request. What does forward mean? It means abort the current request and redo it. Bye to the old one, hello to the new one π₯
π EXCEPTIONS π
Okay this part matters, listen up.
This middleware passes through unknown exceptions to the outside middleware stack. So if you're running this alongside other exception handlers β like Plack::Middleware::StackTrace or Plack::Middleware::HTTPExceptions β you need to be sure to wrap things so that Plack::Middleware::Recursive gets as inner as possible.
Like, the innermost of the inner. The main character of the middleware sandwich π₯ͺ Don't let it get buried, bestie, its exceptions need to escape properly.
π AUTHORS π
- Tatsuhiko Miyagawa
- Masahiro Honma
Kings, honestly. We stan πβ
πΈ SEE ALSO πΈ
PlackPlack::Middleware::HTTPExceptions
Also for the lore girlies: the idea, the code, and the interface are all stolen from Rack::Recursive and paste.recursive. Not even gonna pretend otherwise, the original page is out here being fully transparent about it π
That's a wrap, my love π This page came from the User Contributed Perl Documentation for Plack::...cursive(3), tagged perl v5.42.3, dated 2026-10-18. Slay, stay recursive, and don't forget to wrap it innermost. Periodt ππ¦
π¦ where this page comes from
- fedora 43: perl-Plack 1.0055-1.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- fedora 44: perl-Plack 1.0055-1.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms