logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Coro::Twiggy - Coro interface for Twiggy

Author

        Dmitry E. Oboukhov, <unera@debian.org>

Description

       The server starts Your application in "async" in Coro coroutine and uses its return value to respond to
       client.

       Application have to return an ARRAYREF with the following items:

       •   HTTP-code;

       •   an ARRAYREF that contains headers for response;

       •   an ARRAYREF that contains body of response.

       To stop server destroy server object

Methods

new
       Constructor. Returns server.

       Namedarguments

       host
       port
       service
           PSGI application

   register_service
       (Re)register PSGI application.  Until the event server will respond 503ServiceUnavailable.

Name

       Coro::Twiggy - Coro interface for Twiggy

Synopsis

           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 );

Vcs

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

See Also