Created
January 17, 2014 08:11
-
-
Save ovntatar/8469980 to your computer and use it in GitHub Desktop.
Check Website with http get request
This file contains hidden or 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
| 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