Class: Net::HTTP

Inherits:
Object
  • Object
show all
Defined in:
lib/http_event_logger/adapter/net_http.rb

Instance Method Summary collapse

Instance Method Details

#connect_with_loggingObject


11
12
13
14
# File 'lib/http_event_logger/adapter/net_http.rb', line 11

def connect_with_logging
  HttpEventLogger::Event::Connection.new(@address, @port) unless started?
  connect_without_logging
end

#request_with_logging(req, body = nil, &block) ⇒ Object


18
19
20
21
22
23
24
25
26
# File 'lib/http_event_logger/adapter/net_http.rb', line 18

def request_with_logging(req, body = nil, &block)
  create_request_event(req, body) if started?
  response = nil
  time_taken_in_seconds = ::Benchmark.realtime do
    response = request_without_logging(req, body, &block)
  end
  create_response_event(time_taken_in_seconds, response) if started?
  response
end