line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
28366
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
2
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
44
|
|
3
|
|
|
|
|
|
|
package Juno::Check::HTTP; |
4
|
|
|
|
|
|
|
# ABSTRACT: An HTTP check for Juno |
5
|
|
|
|
|
|
|
$Juno::Check::HTTP::VERSION = '0.010'; |
6
|
1
|
|
|
1
|
|
582
|
use AnyEvent::HTTP; |
|
1
|
|
|
|
|
24951
|
|
|
1
|
|
|
|
|
100
|
|
7
|
1
|
|
|
1
|
|
572
|
use Moo; |
|
1
|
|
|
|
|
12104
|
|
|
1
|
|
|
|
|
7
|
|
8
|
1
|
|
|
1
|
|
1823
|
use MooX::Types::MooseLike::Base qw; |
|
1
|
|
|
|
|
5051
|
|
|
1
|
|
|
|
|
113
|
|
9
|
1
|
|
|
1
|
|
528
|
use namespace::sweep; |
|
1
|
|
|
|
|
19139
|
|
|
1
|
|
|
|
|
8
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
with 'Juno::Role::Check'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has path => ( |
14
|
|
|
|
|
|
|
is => 'ro', |
15
|
|
|
|
|
|
|
isa => Str, |
16
|
|
|
|
|
|
|
default => sub {'/'}, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has headers => ( |
20
|
|
|
|
|
|
|
is => 'ro', |
21
|
|
|
|
|
|
|
isa => HashRef, |
22
|
|
|
|
|
|
|
default => sub { {} }, |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub check { |
26
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
27
|
0
|
|
|
|
|
|
my @hosts = @{ $self->hosts }; |
|
0
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my $path = $self->path; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
foreach my $host (@hosts) { |
31
|
0
|
|
|
|
|
|
my $url = "http://$host" . $path; |
32
|
|
|
|
|
|
|
|
33
|
0
|
0
|
|
|
|
|
$self->has_on_before |
34
|
|
|
|
|
|
|
and $self->on_before->( $self, $host ); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
http_get $url, $self->headers, sub { |
37
|
0
|
|
|
0
|
|
|
my ( $body, $headers ) = @_; |
38
|
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
$self->has_on_result |
40
|
|
|
|
|
|
|
and $self->on_result->( $self, $host, $body, $headers ); |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
if ( $headers->{'Status'} =~ /^2/ ) { |
43
|
0
|
0
|
|
|
|
|
$self->has_on_success |
44
|
|
|
|
|
|
|
and $self->on_success->( $self, $host, $body, $headers ); |
45
|
|
|
|
|
|
|
} else { |
46
|
0
|
0
|
|
|
|
|
$self->has_on_fail |
47
|
|
|
|
|
|
|
and $self->on_fail->( $self, $host, $body, $headers ); |
48
|
|
|
|
|
|
|
} |
49
|
0
|
|
|
|
|
|
}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
return 0; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |