Class: Cleversafe::HttpClient
- Inherits:
-
Object
- Object
- Cleversafe::HttpClient
- Defined in:
- lib/cleversafe/http_client.rb
Constant Summary collapse
- DEFAULTS =
{ :timeout => nil, :open_timeout => nil }
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #delete(path, options = {}) ⇒ Object
- #get(path, options = {}) ⇒ Object
- #head(path, options = {}) ⇒ Object
-
#initialize(url, options = {}) ⇒ HttpClient
constructor
A new instance of HttpClient.
- #post(path, payload, options = {}) ⇒ Object
- #put(path, payload, options = {}) ⇒ Object
- #url_for(*path) ⇒ Object
Constructor Details
#initialize(url, options = {}) ⇒ HttpClient
Returns a new instance of HttpClient.
13 14 15 16 |
# File 'lib/cleversafe/http_client.rb', line 13 def initialize(url, = {}) @url = url @defaults = DEFAULTS.merge() end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
11 12 13 |
# File 'lib/cleversafe/http_client.rb', line 11 def url @url end |
Instance Method Details
#delete(path, options = {}) ⇒ Object
38 39 40 |
# File 'lib/cleversafe/http_client.rb', line 38 def delete(path, = {}) request :delete, path, end |
#get(path, options = {}) ⇒ Object
26 27 28 |
# File 'lib/cleversafe/http_client.rb', line 26 def get(path, = {}) request :get, path, end |
#head(path, options = {}) ⇒ Object
22 23 24 |
# File 'lib/cleversafe/http_client.rb', line 22 def head(path, = {}) request :head, path, end |
#post(path, payload, options = {}) ⇒ Object
30 31 32 |
# File 'lib/cleversafe/http_client.rb', line 30 def post(path, payload, = {}) request :post, path, .merge(:payload => payload) end |
#put(path, payload, options = {}) ⇒ Object
34 35 36 |
# File 'lib/cleversafe/http_client.rb', line 34 def put(path, payload, = {}) request :put, path, .merge(:payload => payload) end |
#url_for(*path) ⇒ Object
18 19 20 |
# File 'lib/cleversafe/http_client.rb', line 18 def url_for(*path) File.join(url, *path) end |