Skip to content

Instantly share code, notes, and snippets.

@kraih
Created March 5, 2012 19:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kraih/1980385 to your computer and use it in GitHub Desktop.
Save kraih/1980385 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use Mojolicious::Lite;
use Coro;
use Mojo::IOLoop;
Mojo::IOLoop->recurring(0 => sub {cede});
hook around_dispatch => sub {
my $next = shift;
async { $next->() };
};
get '/' => sub {
my $self = shift;
my $ua = Mojo::UserAgent->new;
# Comment this line out to see the performance difference
$ua->ioloop->recurring(0 => sub {cede});
$self->render(
text => $ua->get('mojolicio.us')->res->dom->html->head->title->text);
};
app->start;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment