Class: Upcheck::HTTPClient

Inherits:
Object
  • Object
show all
Defined in:
lib/upcheck/http_client.rb

Constant Summary collapse

MAX_REDIRECTS =
5
USER_AGENT =
"Upcheck/#{Upcheck::VERSION} (+https://github.com/MatheusRich/upcheck)"

Instance Method Summary collapse

Constructor Details

#initialize(timeout: Upcheck.configuration.http_timeout) ⇒ HTTPClient

Returns a new instance of HTTPClient.



12
13
14
# File 'lib/upcheck/http_client.rb', line 12

def initialize(timeout: Upcheck.configuration.http_timeout)
  @timeout = timeout
end

Instance Method Details

#get_json(url) ⇒ Object



16
17
18
19
20
# File 'lib/upcheck/http_client.rb', line 16

def get_json(url)
  JSON.parse(get(url))
rescue JSON::ParserError => e
  raise ParseError, "Unable to parse JSON response: #{e.message}"
end