Coro::Twiggy(3pm)

πŸ“¦
version 0.03 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

πŸ’– Coro::Twiggy β€” the vibe ✨

okay so bestie, welcome to Coro::Twiggy (it lives in the User Contributed Perl Documentation section of the manual, section 3pm, iykyk) β€” it's the Coro interface for Twiggy, and honestly? she's serving. 🫢


🌸 NAME 🌸

Coro::Twiggy β€” the Coro interface for Twiggy. that's it, that's the name, no notes. πŸ’…


✨ SYNOPSIS ✨

here's the whole mood, copied exactly because I do not play with code:

use Coro::Twiggy;
use Plack::Request;
use Coro::AnyEvent;

my $application = sub {
    my ($env) = @_;
    my $req = Plack::Request->new($env);

    Coro::AnyEvent::sleep 10;
    ...
    return [
        200,
        [ 'Content-Type' => 'text/html' ],
        [ 'Twiggy response after 10 seconds' ]
    ]
};

my $server = Coro::Twiggy->new(host => '127.0.0.1', port => 8080);
$server->register_service( $application );

like. she sleeps for 10 seconds mid-request and STILL delivers. main character energy fr fr. 😌πŸ”₯


πŸ¦‹ DESCRIPTION πŸ¦‹

so the server starts Your application inside an async in a Coro coroutine, and then it takes whatever your app gives back and uses that to respond to the client. simple as that, no cap. ✨

your Application has to return an ARRAYREF with these three things in it:

  • the HTTP-code;
  • an ARRAYREF that contains the headers for the response;
  • an ARRAYREF that contains the body of the response.
πŸ’€ real talk: to stop the server, you destroy the server object. that's the move. no shutdown method, just let her go.

πŸŽ€ METHODS πŸŽ€

🌈 new

Constructor. Returns server. iconic behaviour honestly. πŸ‘‘

Named arguments:

  • host
  • port
  • service β€” the PSGI application

πŸ’œ register_service

(Re)register the PSGI application. ✨

😭 important: until then, the event server will respond 503 Service Unavailable. so register her before you expect anything cute back, bestie.

🧚 VCS 🧚

<https://github.com/unera/coro-twiggy>

go forth and star her, she deserves it. ⭐


🌸 AUTHOR 🌸

Dmitry E. Oboukhov, <unera@debian.org> β€” thank you king, we appreciate you. 🫢


Copyright (C) 2012 by Dmitry E. Oboukhov

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.

so yeah β€” free software, same terms as Perl itself, Perl version 5.8.8 or any later version you happen to have. slay. πŸ’–


and that's the whole page bestie!! πŸ’… this gorgeous little doc shipped with perl v5.32.0 and was dated 2021-01-09 β€” so if you're reading this, hi from the past, she ate and left no crumbs. πŸŽ€βœ¨ bye!! πŸ¦‹

πŸ“¦ where this page comes from