Class: ThreeScale::Client::HTTPClient::NetHttpPersistent
- Inherits:
-
BaseClient
- Object
- BaseClient
- ThreeScale::Client::HTTPClient::NetHttpPersistent
show all
- Defined in:
- lib/3scale/client/http_client.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseClient
#get_request, #post_request
Constructor Details
Returns a new instance of NetHttpPersistent.
70
71
72
73
74
|
# File 'lib/3scale/client/http_client.rb', line 70
def initialize(host, port)
super
@http = ::Net::HTTP::Persistent.new
@protocol = 'http'
end
|
Class Method Details
.available? ⇒ Boolean
59
60
61
62
63
64
|
# File 'lib/3scale/client/http_client.rb', line 59
def self.available?
prepare
true
rescue LoadError
false
end
|
.prepare ⇒ Object
66
67
68
|
# File 'lib/3scale/client/http_client.rb', line 66
def self.prepare
require 'net/http/persistent'
end
|
Instance Method Details
#full_uri(path) ⇒ Object
91
92
93
|
# File 'lib/3scale/client/http_client.rb', line 91
def full_uri(path)
URI.join "#{@protocol}://#{@host}:#{@port}", path
end
|
#get(path) ⇒ Object
80
81
82
83
|
# File 'lib/3scale/client/http_client.rb', line 80
def get(path)
uri = full_uri(path)
@http.request(uri, get_request(path))
end
|
#post(path, payload) ⇒ Object
86
87
88
89
|
# File 'lib/3scale/client/http_client.rb', line 86
def post(path, payload)
uri = full_uri(path)
@http.request(uri, post_request(path, payload))
end
|
#ssl! ⇒ Object
76
77
78
|
# File 'lib/3scale/client/http_client.rb', line 76
def ssl!
@protocol = 'https'
end
|