Class: HTTPI::Adapter::HTTPClient
- Inherits:
-
Object
- Object
- HTTPI::Adapter::HTTPClient
- Defined in:
- lib/httpi/adapter/httpclient.rb
Overview
HTTPI::Adapter::HTTPClient
Adapter for the HTTPClient client. rubygems.org/gems/httpclient
Instance Method Summary collapse
-
#client ⇒ Object
Returns a memoized
HTTPClient
instance. -
#delete(request) ⇒ Object
Executes an HTTP DELETE request.
-
#get(request) ⇒ Object
Executes an HTTP GET request.
-
#head(request) ⇒ Object
Executes an HTTP HEAD request.
-
#initialize(request = nil) ⇒ HTTPClient
constructor
A new instance of HTTPClient.
-
#post(request) ⇒ Object
Executes an HTTP POST request.
-
#put(request) ⇒ Object
Executes an HTTP PUT request.
Constructor Details
#initialize(request = nil) ⇒ HTTPClient
Returns a new instance of HTTPClient.
12 13 |
# File 'lib/httpi/adapter/httpclient.rb', line 12 def initialize(request = nil) end |
Instance Method Details
#client ⇒ Object
Returns a memoized HTTPClient
instance.
16 17 18 |
# File 'lib/httpi/adapter/httpclient.rb', line 16 def client @client ||= ::HTTPClient.new end |
#delete(request) ⇒ Object
Executes an HTTP DELETE request.
54 55 56 57 58 |
# File 'lib/httpi/adapter/httpclient.rb', line 54 def delete(request) do_request request do |url, headers| client.delete url, headers end end |
#get(request) ⇒ Object
Executes an HTTP GET request.
22 23 24 25 26 |
# File 'lib/httpi/adapter/httpclient.rb', line 22 def get(request) do_request request do |url, headers| client.get url, nil, headers end end |
#head(request) ⇒ Object
Executes an HTTP HEAD request.
38 39 40 41 42 |
# File 'lib/httpi/adapter/httpclient.rb', line 38 def head(request) do_request request do |url, headers| client.head url, nil, headers end end |
#post(request) ⇒ Object
Executes an HTTP POST request.
30 31 32 33 34 |
# File 'lib/httpi/adapter/httpclient.rb', line 30 def post(request) do_request request do |url, headers, body| client.post url, body, headers end end |
#put(request) ⇒ Object
Executes an HTTP PUT request.
46 47 48 49 50 |
# File 'lib/httpi/adapter/httpclient.rb', line 46 def put(request) do_request request do |url, headers, body| client.put url, body, headers end end |