IO::Lam...:Server(3)

πŸ“¦ version 1.34, in alpine 3.24

🌸 NAME 🌸

okay so this is the IO::Lambda::HTTP::Server(3) page β€” filed under User Contributed Perl Documentation, bestie β€” and it's all about IO::Lambda::HTTP::Server, a simple httpd server. periodt. πŸ’…

✨ DESCRIPTION ✨

The module exports a single function http_server that accepts a callback and a socket, with optional parameters. The callback accepts a HTTP::Request object, and is expected to return either a HTTP::Response object or a lambda that in turn returns a HTTP::Response object. no cap. πŸ¦‹

πŸŽ€ SYNOPSIS πŸŽ€

   use HTTP::Request;
   use IO::Lambda qw(:all);
   use IO::Lambda::HTTP qw(http_request);
   use IO::Lambda::HTTP::Server;

   my $server = http_server {
        my $req = shift;
        if ( $req->uri =~ /weather/) {
                context( HTTP::Request-> new( GET => "http://www.google.com/?q=weather"));
                return &http_request;
        } else {
                return HTTP::Response->new(200, 'OK', ['Content-Type' => 'text/plain'], "hello world");
        }
   } "localhost:80";
   $server->start; # runs in 'background' now

πŸ’… API πŸ’…

🫢 http_server &callback, $socket, [ %options ] 🫢

Creates lambda that listens on $socket, that is either a IO::Socket::INET object or a string such as "localhost" or "127.0.0.1:9999". 🌈

The callback accepts a HTTP::Request object, and is expected to return either a HTTP::Response object or a lambda that in turn returns a HTTP::Response object. fr fr. πŸ’–

πŸ“ Options πŸ“

  • timeout $integer β€” connection timeout or a deadline.
  • shutdown β€” enter a graceful shutdown mode β€” stop accepting new connections, handle the running ones, and stop after all connections are served.

πŸ”₯ SEE ALSO πŸ”₯

  • IO::Lambda
  • HTTP::Request
  • HTTP::Response

πŸ‘‘ AUTHOR πŸ‘‘

Dmitry Karasik, <dmitry@karasik.eu.org>. 🫢


that's the whole vibe, bestie β€” this page is from perl v5.42.2, dated 2026-02-15, and it's the IO::Lam...:Server(3) manual. mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from