Skip to content

Instantly share code, notes, and snippets.

@ovntatar
Created January 17, 2014 08:11
Show Gist options
  • Select an option

  • Save ovntatar/8469980 to your computer and use it in GitHub Desktop.

Select an option

Save ovntatar/8469980 to your computer and use it in GitHub Desktop.
Check Website with http get request
package My::UserAgent
use Mojo::UserAgent;
use Moo;
has _ua => (
is => 'ro',
lazy => 1,
init_arg => 0,
default => sub {
my $ua = Mojo::UserAgent->new;
$ua->on(error => sub {
my ($ua, $err) = @_;
die $err;
});
return $ua;
}
);
sub getHttpCode {
shift->_ua->max_redirects(3)->get(shift)->res->code;
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment