Module: FIR::Http

Included in:
Util::ClassMethods
Defined in:
lib/fir/util/http.rb

Constant Summary collapse

DEFAULT_TIMEOUT =
300

Instance Method Summary collapse

Instance Method Details

#get(url, params = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fir/util/http.rb', line 7

def get(url, params = {})
  begin
    res = ::RestClient::Request.execute(
      method:  :get,
      url:     url,
      timeout: DEFAULT_TIMEOUT,
      headers: default_headers.merge(params: params)
    )
  rescue => e
    logger.error e.message.to_s + ' - ' + e.response.to_s
    exit 1
  end

  JSON.parse(res.body.force_encoding('UTF-8'), symbolize_names: true)
end