Module: PaapiMini::Http
- Defined in:
- lib/http_client.rb
Defined Under Namespace
Classes: Error
Class Method Summary collapse
Class Method Details
.post(uri, payload, headers, options = {}) ⇒ Object
Post
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/http_client.rb', line 16 def self.post(uri, payload, headers, = {}) begin parsed_uri, http = create_http(uri, .has_key?(:proxy_url) ? [:proxy_url] : nil) req = Net::HTTP::Post.new(parsed_uri.request_uri) headers.each do |key, value| req[key.to_s] = value.to_s end if .has_key?(:basic_auth) req.basic_auth([:basic_auth][0], [:basic_auth][1]) end req.body = payload http.request(req) rescue => e raise PaapiMini::Http::Error.new("#{e.} #{e.backtrace}" ) end end |