Last active
July 29, 2016 17:55
-
-
Save mpapec/9688b87ecf089bba1d050b0d9926b47a 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; | |
use Mojo::UserAgent; | |
use Mojo::IOLoop; | |
get '/get' => sub { | |
my $c = shift; | |
$c->render(text => "TEST"); | |
}; | |
get '/test' => sub { | |
my $c = shift; | |
# my $ua = Mojo::UserAgent->new; | |
my $ua = $c->ua; | |
Mojo::IOLoop->delay( | |
# $c->delay( | |
sub { | |
my $delay = shift; | |
$ua->get("http://127.0.0.1:3000/get" => $delay->begin); | |
warn "so far so good"; | |
}, | |
sub { | |
warn "we are still good!"; | |
my ($delay, $tx) = @_; | |
$c->render(text => $tx->res->body); | |
} | |
); | |
}; | |
app->start; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment