lib/onering/cli/call.rb in onering-client-0.0.72 vs lib/onering/cli/call.rb in onering-client-0.0.73

- old
+ new

@@ -23,18 +23,26 @@ Options: EOS opt :method, "The HTTP method to use when performing the request", :default => 'get', :short => "-m", :type => :string opt :query, "A query string attribute to add to the request in the form of NAME=VALUE", :short => '-a', :type => :string, :multi => true + opt :header, "A 'Name: Value' header to add to the request", :short => '-H', :type => :string, :multi => true end end def self.run(args) data = STDIN.read() unless STDIN.tty? + headers = { + 'Content-Type' => 'application/json' + }.merge(Hash[@opts[:header].collect{|i| + i.split(/\:\s*/,2) + }]) + rv = @api.request(@opts[:method], args.first, { - :body => data, - :query => Hash[@opts[:query].collect{|i| + :body => data, + :headers => headers, + :query => Hash[@opts[:query].collect{|i| i.split('=',2) }] }.compact) return (rv.parsed_response rescue rv.response.body) \ No newline at end of file