Class: Delighted::HTTPAdapter
- Inherits:
-
Object
- Object
- Delighted::HTTPAdapter
- Defined in:
- lib/delighted/http_adapter.rb
Constant Summary collapse
- REQUEST_CLASSES =
{ :get => Net::HTTP::Get, :post => Net::HTTP::Post, :delete => Net::HTTP::Delete, :put => Net::HTTP::Put }
Instance Method Summary collapse
Instance Method Details
#request(method, uri, headers = {}, data = nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/delighted/http_adapter.rb', line 10 def request(method, uri, headers = {}, data = nil) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_PEER request = REQUEST_CLASSES[method].new(uri.request_uri) headers.each { |k,v| request[k] = v } request.body = data response = http.request(request) HTTPResponse.new(response.code, response.to_hash, response.body) end |