Created
September 26, 2018 09:28
-
-
Save jhthorsen/a7a7589dc17082a896a9efd3d204235d to your computer and use it in GitHub Desktop.
Show how you need prevent the object from going out of scope
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
#!perl | |
use Mojolicious::Lite; | |
get '/' => sub { | |
my $c = shift; | |
my $ua = Mojo::UserAgent->new; | |
# Try keeping this object alive with http://localhost:3000?keep_alive=1 | |
$c->stash(ua => $ua) if $c->param('keep_alive'); | |
$c->render_later; | |
$ua->get('https://www.solfaktor.no/', sub { | |
my ($ua, $tx) = @_; | |
$c->render(text => $tx->res->code); | |
}); | |
}; | |
app->start; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment