Skip to content

Instantly share code, notes, and snippets.

@mpapec
Last active July 29, 2016 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpapec/9688b87ecf089bba1d050b0d9926b47a to your computer and use it in GitHub Desktop.
Save mpapec/9688b87ecf089bba1d050b0d9926b47a to your computer and use it in GitHub Desktop.
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