-
-
Save mpapec/434884dcf7094468096017ad4e05860e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Mojolicious::Lite; | |
helper iodelay => sub { | |
my $cb = pop; | |
my ($c, @steps) = @_; | |
push @steps, sub { | |
# log err if $_[1] | |
shift; | |
$c->$cb(@_); | |
}; | |
Mojo::IOLoop->delay(@steps)->catch($steps[-1]); | |
}; | |
any '/' => sub { | |
my $c = shift; | |
$c->iodelay( | |
sub{ | |
my $delay = shift; | |
$delay->pass(text => 'hello world'); | |
Mojo::IOLoop->timer(1 => $delay->begin); | |
}, | |
sub { | |
my (undef, $err, @args) = @_; | |
$c->reply->exception($err) if $err; | |
$c->render(@args); | |
}, | |
); | |
}; | |
app->start; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment