5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/airborne/rest_client_requester.rb', line 5
def make_request(method, url, options = {})
= .merge(options[:headers] || {})
timeout = options.fetch(:timeout, 60)
res = if method == :post || method == :patch || method == :put
begin
request_body = options[:body].nil? ? '' : options[:body]
request_body = request_body.to_json if options[:body].is_a?(Hash)
RestClient::Request.execute(:method => method, :url => get_url(url), :payload => request_body,
:headers => , :verify_ssl => Airborne.configuration.verify_ssl,
:timeout => timeout)
rescue RestClient::Exception => e
e.response
end
else
begin
RestClient::Request.execute(:method => method, :url => get_url(url), :headers => ,
:verify_ssl => Airborne.configuration.verify_ssl,
:timeout => timeout)
rescue RestClient::Exception => e
e.response
end
end
res
end
|