Module: Pebblebed::Http
- Defined in:
- lib/pebblebed/http.rb
Defined Under Namespace
Classes: CurlResult
Class Method Summary collapse
- .delete(url, params, &block) ⇒ Object
- .get(url = nil, params = nil, &block) ⇒ Object
- .post(url, params, &block) ⇒ Object
- .put(url, params, &block) ⇒ Object
Class Method Details
.delete(url, params, &block) ⇒ Object
80 81 82 83 |
# File 'lib/pebblebed/http.rb', line 80 def self.delete(url, params, &block) url, params = url_and_params_from_args(url, params, &block) handle_curl_response(Curl::Easy.http_delete(url_with_params(url, params))) end |
.get(url = nil, params = nil, &block) ⇒ Object
57 58 59 60 |
# File 'lib/pebblebed/http.rb', line 57 def self.get(url = nil, params = nil, &block) url, params = url_and_params_from_args(url, params, &block) handle_curl_response(Curl::Easy.perform(url_with_params(url, params))) end |
.post(url, params, &block) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/pebblebed/http.rb', line 62 def self.post(url, params, &block) url, params = url_and_params_from_args(url, params, &block) content_type, body = serialize_params(params) handle_curl_response(Curl::Easy.http_post(url.to_s, body) do |curl| curl.headers['Accept'] = 'application/json' curl.headers['Content-Type'] = content_type end) end |
.put(url, params, &block) ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/pebblebed/http.rb', line 71 def self.put(url, params, &block) url, params = url_and_params_from_args(url, params, &block) content_type, body = serialize_params(params) handle_curl_response(Curl::Easy.http_put(url.to_s, body) do |curl| curl.headers['Accept'] = 'application/json' curl.headers['Content-Type'] = content_type end) end |