Plack::Handler(3)
β¨ Plack::Handler β¨
okay bestie, so this is the Perl manual page for Plack::Handler β it's the lil connector that hooks your PSGI apps up to web servers π«Ά
πΈ NAME πΈ
Plack::Handler β Connects PSGI applications and Web servers π
π SYNOPSIS π
so here's the whole vibe, fr fr:
package Plack::Handler::AwesomeWebServer;
sub new {
my($class, %opt) = @_;
...
return $self;
}
sub run {
my($self, $app) = @_;
# launch the AwesomeWebServer and run $app in the loop
}
# then from command line
plackup -s AwesomeWebServer -a app.psgi
periodt. that's literally it. π
π¦ DESCRIPTION π¦
Plack::Handler defines an adapter (connector) interface β like, it adapts plackup and Plack::Runner to all kinds of PSGI web servers, for example Apache2 for mod_perl and Standalone for HTTP::Server::PSGI. it's giving matchmaker energy ngl π
it's an empty class btw. so as long as you implement the methods defined as a Server adapter interface, you do not need to inherit from Plack::Handler at all. no bloodline requirement, we're all self-made here π
if you're writing a new handler for an existing web server, the author recommends you include the full name of the server module after the Plack::Handler prefix β like Plack::Handler::Net::Server::Coro if you're writing a handler for Net::Server::Coro. that way you'll be using the plackup command line option like:
plackup -s Net::Server::Coro
which makes it sooo easy to figure out which web server you're actually about to use. iykyk β¨
π METHODS π
π new
$server = FooBarServer->new(%args);
creates a new adapter object, slay. %args can take arbitrary parameters to configure server environments, but the common ones are:
portβ the port number the server listens to πhostβ the address the server listens to. set it toundefto listen on any interface π
π run
$server->run($app);
starts the server process, and whenever a request comes in, it runs the PSGI application you passed in $app in the loop. main character energy, honestly π₯
π§ register_service
$server->register_service($app);
this one's an optional interface, for if your server should run in parallel with another event loop β particularly AnyEvent. it's the same as "run" but it doesn't run the main loop. so like, run's chill cousin π
π SEE ALSO π
rackup
reminder bestie: that prefix-naming tip is a recommendation, not a rule β the only law here is "implement the interface." go off π
and that's a wrap, gorgeous π this page came from the User Contributed Perl Documentation collection, version perl v5.42.3, dated 2026-10-18. go build something iconic π
β¨
π¦ 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