Class: Rpruby::HttpClient Private
- Inherits:
-
Object
- Object
- Rpruby::HttpClient
- Defined in:
- lib/rpruby/http_client.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
-
#initialize ⇒ HttpClient
constructor
private
A new instance of HttpClient.
- #send_request(verb, path, options = {}) ⇒ Object private
Constructor Details
#initialize ⇒ HttpClient
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of HttpClient.
6 7 8 |
# File 'lib/rpruby/http_client.rb', line 6 def initialize create_client end |
Instance Method Details
#send_request(verb, path, options = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rpruby/http_client.rb', line 10 def send_request(verb, path, = {}) path.prepend("/api/v1/#{Settings.instance.project}/") path.prepend(origin) unless use_persistent? 3.times do begin response = @http.request(verb, path, ) rescue StandardError => e puts "Request #{request_info(verb, path)} produced an exception:" puts e recreate_client else return response.parse(:json) if response.status.success? = "Request #{request_info(verb, path)} returned code #{response.code}." << " Response:\n#{response}" unless response.to_s.empty? puts end end end |