Module: Mio::Requests

Defined in:
lib/mio/requests.rb

Class Method Summary collapse

Class Method Details

.make_request(type, agent, url, opts, body = nil, content_type = 'application/vnd.nativ.mio.v1+json', accept = 'application/json') ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/mio/requests.rb', line 4

def self.make_request type, agent, url, opts, body=nil, content_type='application/vnd.nativ.mio.v1+json', accept='application/json'
  if content_type.nil?
    content_type = 'application/vnd.nativ.mio.v1+json'
  end
  agent.method(type).call do |r|
    r.url url
    unless body.nil?
      if content_type.include? 'json'
        r.body = body.to_json
      else
        r.body = body
      end
    end
    r.headers[:content_type] = content_type
    r.headers[:accept]= accept
  end
end