Class: Wary::Check::HttpStatus
- Inherits:
-
Object
- Object
- Wary::Check::HttpStatus
- Includes:
- Wary::Check
- Defined in:
- lib/wary/check/http_status.rb
Instance Attribute Summary
Attributes included from Wary::Check
Instance Method Summary collapse
-
#initialize(options) ⇒ HttpStatus
constructor
A new instance of HttpStatus.
- #status ⇒ Object
Methods included from Wary::Check
Constructor Details
#initialize(options) ⇒ HttpStatus
Returns a new instance of HttpStatus.
9 10 11 12 13 |
# File 'lib/wary/check/http_status.rb', line 9 def initialize() @url = .fetch(:url) @http_client = .fetch(:http_client) { HTTPClient.new } configure() end |
Instance Method Details
#status ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/wary/check/http_status.rb', line 15 def status begin response = @http_client.get_response(@url) rescue => e return failure("#{@url} down (#{e.})") end if response.code == "200" ok((response)) else alert("#{@url} (#{response.code} #{response.})") end end |