module Dtmcli::Proxy

Public Instance Methods

check_status(resp) click to toggle source
# File lib/dtmcli/proxy.rb, line 16
def check_status(resp)
  code = resp.status
  if code != 200
    raise "Dtmcli rpc error: bad http response status = #{code} resp = #{resp.to_hash}"
  end
  return resp
end
execute(method, url, opts={}) { |resp| ... } click to toggle source
# File lib/dtmcli/proxy.rb, line 5
def execute(method, url, opts={}, &block)
  resp = Faraday.send(method, url) do |req|
    req.headers = opts[:headers] || {'Content-Type'=>'application/json'}
    req.params  = opts[:params]  || {}
    req.body    = opts[:body]    || {}
  end

  check_status(resp)
  yield resp if block
end