Module: VCAP::Services::Api::SynchronousHttpRequest

Defined in:
lib/services/api/async_requests.rb

Class Method Summary collapse

Class Method Details

.request(url, token, verb, timeout, msg = VCAP::Services::Api::EMPTY_REQUEST) ⇒ Object



50
51
52
53
54
55
56
57
58
59
# File 'lib/services/api/async_requests.rb', line 50

def self.request(url, token, verb, timeout, msg=VCAP::Services::Api::EMPTY_REQUEST)
  header = {
    VCAP::Services::Api::GATEWAY_TOKEN_HEADER => token,
    'Content-Type' => 'application/json',
  }
  body = msg.encode
  client = HTTPClient.new
  msg = client.request(verb.to_sym, url, :body => body, :header => header)
  [msg.code, msg.body]
end