Class: Excon::Connection
- Inherits:
-
Object
- Object
- Excon::Connection
- Defined in:
- lib/binnacle/http_logging/adapters/excon.rb
Instance Method Summary collapse
- #_httplog_url(datum) ⇒ Object
- #orig_request ⇒ Object
- #orig_request_call ⇒ Object
- #orig_response ⇒ Object
- #request(params, &block) ⇒ Object
- #request_call(datum) ⇒ Object
- #response(datum = {}) ⇒ Object
Instance Method Details
#_httplog_url(datum) ⇒ Object
6 7 8 |
# File 'lib/binnacle/http_logging/adapters/excon.rb', line 6 def _httplog_url(datum) "#{datum[:scheme]}://#{datum[:host]}:#{datum[:port]}#{datum[:path]}#{datum[:query]}" end |
#orig_request ⇒ Object
10 |
# File 'lib/binnacle/http_logging/adapters/excon.rb', line 10 alias_method :orig_request, :request |
#orig_request_call ⇒ Object
30 |
# File 'lib/binnacle/http_logging/adapters/excon.rb', line 30 alias_method :orig_request_call, :request_call |
#orig_response ⇒ Object
42 |
# File 'lib/binnacle/http_logging/adapters/excon.rb', line 42 alias_method :orig_response, :response |
#request(params, &block) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/binnacle/http_logging/adapters/excon.rb', line 11 def request(params, &block) datum = @data.merge(params) url = _httplog_url(datum) return orig_request(params, &block) unless Binnacle::HttpLogger.allow?(url) result = nil @binnacle_bm = Benchmark.realtime do result = orig_request(params, &block) end datum[:headers] = @data[:headers].merge(datum[:headers] || {}) if Binnacle::HttpLogger.allow?(url) @binnacle_method = datum[:method] end result end |
#request_call(datum) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/binnacle/http_logging/adapters/excon.rb', line 31 def request_call(datum) url = _httplog_url(datum) if Binnacle::HttpLogger.allow?(url) @binnacle_headers = datum[:headers] @binnacle_data = datum[:body] # if datum[:method] == :post @binnacle_method = datum[:method] end orig_request_call(datum) end |
#response(datum = {}) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/binnacle/http_logging/adapters/excon.rb', line 43 def response(datum={}) url = _httplog_url(datum) return orig_response(datum) unless Binnacle::HttpLogger.allow?(url) uri = URI(url) url_without_query = "#{uri.scheme}://#{uri.host}:#{uri.port}#{uri.path}" bm = Benchmark.realtime do datum = orig_response(datum) end response = datum[:response] headers = response[:headers] || {} Binnacle::HttpLogger.signal(url_without_query, @binnacle_method, datum[:host], datum[:port], uri.path, uri.query, response[:status], @binnacle_bm, @binnacle_headers, response[:body], headers['Content-Encoding'], headers['Content-Type'], @binnacle_data) datum end |