Class: HTTPI::Adapter::NetHTTP

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#clientObject

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.

See Also:



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.

See Also:



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.

See Also:



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.

See Also:



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.

See Also:



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