NAME
Juno::Check::HTTP - An HTTP check for Juno
VERSION
version 0.010
DESCRIPTION
my $juno = Juno->new(
checks => {
HTTP => {
hosts => [ 'tom', 'jerry' ],
path => '/my/custom/path',
},
}
);
ATTRIBUTES
path
The path that is checked.
Default: /.
headers
A hashref or additional headers to send to the server. This is useful if you want to run a request to a server requesting a specific website (i.e., VirtualHost).
hosts
An arrayref of hosts to check, overriding the default given to Juno.pm.
my $juno = Juno->new(
hosts => [ 'Tom', 'Jerry' ],
checks => {
HTTP => {
hosts => [ 'Micky', 'Mini' ], # this overrides tom and jerry
},
},
);
Now the HTTP check will not check Tom and Jerry, but rather Micky and Mini.
This attribute derives from Juno::Role::Check.
interval
An integer of seconds between each check (nor per-host).
This attribute derives from Juno::Role::Check.
on_success
A coderef to run when making a successful request. This is done by checking the HTTP response header has a status code starting with 200 (which is by HTTP RFC a successful response).
This attribute derives from Juno::Role::Check.
on_fail
A coderef to run when making an unsuccessful request. This is the opposite of on_success
described above.
This attribute derives from Juno::Role::Check.
on_result
A coderef to run when getting a response - any response. This is what you use in case you want more control over what's going on.
This attribute derives from Juno::Role::Check.
on_before
A coderef to run before making a request. A useful example of this is timing the request.
use Juno;
use AnyEvent;
my $cv = AnyEvent->condvar;
my %time = (
tom => AnyEvent->now,
);
my $juno = Juno->new(
checks => {
HTTP => {
on_before => sub {
my $host = $_[1];
$time{$host} = AnyEvent->now;
},
on_result => sub {
my $host = $_[1];
my $time = AnyEvent->now - $time{'tom'};
print "It took $time to run the request to $host\n";
},
},
},
);
watcher
Holds the watcher for the HTTP check timer.
This attribute derives from Juno::Role::Check.
METHODS
check
Juno will call this method for you. You should not call it yourself.
run
Juno will call this method for you. You should not call it yourself.
AUTHORS
Sawyer X <xsawyerx@cpan.org>
Adam Balali <adamba@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Sawyer X.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.