Class: Knowtify::ExconHandler
- Inherits:
-
Object
- Object
- Knowtify::ExconHandler
- Defined in:
- lib/knowtify/handlers/excon_handler.rb
Instance Attribute Summary collapse
-
#http_client ⇒ Object
Returns the value of attribute http_client.
Instance Method Summary collapse
- #config ⇒ Object
-
#initialize ⇒ ExconHandler
constructor
A new instance of ExconHandler.
- #post(request, count = 0) ⇒ Object
- #request_options(request) ⇒ Object
Constructor Details
#initialize ⇒ ExconHandler
Returns a new instance of ExconHandler.
7 8 9 10 11 12 13 14 |
# File 'lib/knowtify/handlers/excon_handler.rb', line 7 def initialize opts = { :idempotent => true, :retry_limit => config.max_retries }.merge(config.) opts[:instrumentor] = Excon::StandardInstrumentor if config.debug? # output full request data if debugging @http_client = Excon.new(config.base_url,opts) end |
Instance Attribute Details
#http_client ⇒ Object
Returns the value of attribute http_client.
5 6 7 |
# File 'lib/knowtify/handlers/excon_handler.rb', line 5 def http_client @http_client end |
Instance Method Details
#config ⇒ Object
34 35 36 |
# File 'lib/knowtify/handlers/excon_handler.rb', line 34 def config Knowtify.config end |
#post(request, count = 0) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/knowtify/handlers/excon_handler.rb', line 22 def post(request,count=0) resp = Knowtify::Response.new(count) resp.raw_response = http_client.post((request)) resp.body = resp.raw_response.body resp.http_code = resp.raw_response.status if resp.retry? post(request,count + 1) else resp end end |
#request_options(request) ⇒ Object
16 17 18 19 20 |
# File 'lib/knowtify/handlers/excon_handler.rb', line 16 def (request) {:path => request.path, :body => request.params.to_json, :headers => request.headers}.merge(request.) end |