Padre-Plugin-Plack

 view release on metacpan or  search on metacpan

share/dot-psgi/echo-stream.psgi  view on Meta::CPAN

use AnyEvent;
my $app = sub {
    my $env = shift;

    warn "This app needs a server that supports psgi.streaming"
        unless $env->{'psgi.streaming'};

    my $cv = AE::cv;
    return sub {
        my $respond = shift;
        my $w = $respond->([ 200, ['X-Foo' => 'bar', 'Content-Type' => 'text/plain'] ]);
        my $t; $t = AE::timer 0, 1, sub {
            $t;
            # TODO handle client disconnect (broken pipe) and poll_cb
            $w->write(time . "\n");
        };



( run in 0.224 second using v1.01-cache-2.11-cpan-4d50c553e7e )