19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/admin-vmc-plugin/curl.rb', line 19
def curl
mode = input[:mode].upcase
path = input[:path]
body = input[:body]
= {}
input[:headers].each do |h|
k, v = h.split(/\s*:\s*/, 2)
[k.downcase] = v
end
content = ["content-type"]
accept = ["accept"]
content ||= :json if body
accept ||= :json unless %w(DELETE HEAD).include?(mode)
req, res =
client.base.request_raw(
mode,
remove_leading_slash(path),
:headers => ,
:accept => accept,
:payload => body,
:content => body && content)
if [:json, "application/json"].include? accept
puts MultiJson.dump(res, :pretty => true)
else
puts res
end
end
|