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 to undef to 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