Class: Upcheck::HTTPClient
- Inherits:
-
Object
- Object
- Upcheck::HTTPClient
- 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
- #get_json(url) ⇒ Object
-
#initialize(timeout: Upcheck.configuration.http_timeout) ⇒ HTTPClient
constructor
A new instance of HTTPClient.
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.}" end |