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

DESCRIPTION

The server starts Your application in \*(L"async\*(R" in Coro coroutine and uses its return value to respond to client.

Application have to return an \s-1ARRAYREF\s0 with the following items:

  • HTTP-code;

  • an \s-1ARRAYREF\s0 that contains headers for response;

  • an \s-1ARRAYREF\s0 that contains body of response.

To stop server destroy server object

METHODS

new

Constructor. Returns server.

Named arguments

host
port
service

\s-1PSGI\s0 application

register_service

(Re)register \s-1PSGI\s0 application. Until the event server will respond 503 Service Unavailable.

VCS

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

AUTHOR

Dmitry E. Oboukhov, <[email protected]>

COPYRIGHT AND LICENSE

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.