Class: HTTPI::Adapter::NetHTTP
- Inherits:
-
Object
- Object
- HTTPI::Adapter::NetHTTP
- Defined in:
- lib/httpi/adapter/net_http.rb
Overview
HTTPI::Adapter::NetHTTP
Adapter for the Net::HTTP client. ruby-doc.org/stdlib/libdoc/net/http/rdoc/
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#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) ⇒ NetHTTP
constructor
A new instance of NetHTTP.
-
#post(request) ⇒ Object
Executes an HTTP POST request.
-
#put(request) ⇒ Object
Executes an HTTP PUT request.
Constructor Details
#initialize(request) ⇒ NetHTTP
Returns a new instance of NetHTTP.
13 14 15 |
# File 'lib/httpi/adapter/net_http.rb', line 13 def initialize(request) self.client = new_client request end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
17 18 19 |
# File 'lib/httpi/adapter/net_http.rb', line 17 def client @client end |
Instance Method Details
#delete(request) ⇒ Object
Executes an HTTP DELETE request.
55 56 57 58 59 |
# File 'lib/httpi/adapter/net_http.rb', line 55 def delete(request) do_request :delete, request do |http, delete| http.request delete end end |
#get(request) ⇒ Object
Executes an HTTP GET request.
21 22 23 24 25 |
# File 'lib/httpi/adapter/net_http.rb', line 21 def get(request) do_request :get, request do |http, get| http.request get end end |
#head(request) ⇒ Object
Executes an HTTP HEAD request.
38 39 40 41 42 |
# File 'lib/httpi/adapter/net_http.rb', line 38 def head(request) do_request :head, request do |http, head| http.request head end end |
#post(request) ⇒ Object
Executes an HTTP POST request.
29 30 31 32 33 34 |
# File 'lib/httpi/adapter/net_http.rb', line 29 def post(request) do_request :post, request do |http, post| post.body = request.body http.request post end end |
#put(request) ⇒ Object
Executes an HTTP PUT request.
46 47 48 49 50 51 |
# File 'lib/httpi/adapter/net_http.rb', line 46 def put(request) do_request :put, request do |http, put| put.body = request.body http.request put end end |