Subscribed unsubscribe Subscribe Subscribe

plackでanyeventで止めてからレスポンスを返す

のはこんな感じでいいんですかね。

AnyEvent

use strict;
use warnings;

use AnyEvent;

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

    sub {
        my $response = shift;
        my $cv = AE::cv;
        $cv->cb(sub {
                $_[0]->recv;
                $response->([200, [ 'Content-Type', 'text/plain' ], ["end"] ]);    
            });

        my $timer; $timer = AE::timer 1, 0, sub {
            undef $timer;
            $cv->send;
        };
    };
};