Class: Rack::TrafficLogger::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/traffic_logger/request.rb

Overview

noinspection RubyStringKeysInHashInspection

Instance Method Summary collapse

Constructor Details

#initialize(logger) ⇒ Request

Returns a new instance of Request.



11
12
13
14
15
# File 'lib/rack/traffic_logger/request.rb', line 11

def initialize(logger)
  @logger = logger
  @id = SecureRandom.hex 4
  @started_at = Time.now
end

Instance Method Details

#finish(response) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/rack/traffic_logger/request.rb', line 22

def finish(response)
  @code = Array === response ? response.first.to_i : 0
  @options = @logger.options.for(@verb, @code)
  if @options.basic?
    log_request @env
    log_response @env, response if @code > 0
  end
end

#start(env) ⇒ Object



17
18
19
20
# File 'lib/rack/traffic_logger/request.rb', line 17

def start(env)
  @verb = env['REQUEST_METHOD'].downcase.to_sym
  @env = env
end