add get_message method for http backends

This commit is contained in:
Colin Gagnaire 2019-03-19 09:38:40 +01:00
parent f69f1a04a2
commit 86b997f3b4
3 changed files with 22 additions and 5 deletions

View File

@ -359,10 +359,10 @@ sub request {
eval "$options{request}->{critical_status}") {
$status = 'critical';
} elsif (defined($options{request}->{warning_status}) && $options{request}->{warning_status} ne '' &&
eval "$options{request}->{warning_status}") {
eval "$options{request}->{warning_status}") {
$status = 'warning';
} elsif (defined($options{request}->{unknown_status}) && $options{request}->{unknown_status} ne '' &&
eval "$options{request}->{unknown_status}") {
eval "$options{request}->{unknown_status}") {
$status = 'unknown';
}
};
@ -398,8 +398,13 @@ sub get_code {
return $self->{response_code};
}
1;
sub get_message {
my ($self, %options) = @_;
return $http_code_explained->{$self->{response_code}};
}
1;
__END__

View File

@ -208,10 +208,10 @@ sub request {
eval "$request_options->{critical_status}") {
$status = 'critical';
} elsif (defined($request_options->{warning_status}) && $request_options->{warning_status} ne '' &&
eval "$request_options->{warning_status}") {
eval "$request_options->{warning_status}") {
$status = 'warning';
} elsif (defined($request_options->{unknown_status}) && $request_options->{unknown_status} ne '' &&
eval "$request_options->{unknown_status}") {
eval "$request_options->{unknown_status}") {
$status = 'unknown';
}
};
@ -250,6 +250,12 @@ sub get_code {
return $self->{response}->code();
}
sub get_message {
my ($self, %options) = @_;
return $self->{response}->message();
}
1;
__END__

View File

@ -190,6 +190,12 @@ sub get_code {
return $self->{'backend_' . $self->{http_backend}}->get_code();
}
sub get_message {
my ($self, %options) = @_;
return $self->{'backend_' . $self->{http_backend}}->get_message();
}
1;
__END__