miyagawa (owner)

Revisions

gist: 208905 Download_button fork
public
Public Clone URL: git://gist.github.com/208905.git
Embed All Files: show embed
eg/dot-psgi/echo-coro.psgi #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use Coro;
use Coro::AnyEvent;
use Coro::Timer;
use IO::Handle::Util qw(io_from_getline);
 
my $app = sub {
    my $env = shift;
 
    die "You should run this app with Coro backend"
        unless $env->{'psgi.multithread'};
 
    my $count;
    my $body = io_from_getline sub {
        return if $count++ > 5;
        Coro::Timer::sleep 1;
        return time . "\n";
    };
 
    return [ 200, ['X-Foo' => 'bar'], $body ];
};