Class: Rack::TrafficLogger::Request
- Inherits:
-
Object
- Object
- Rack::TrafficLogger::Request
- Defined in:
- lib/rack/traffic_logger/request.rb
Overview
noinspection RubyStringKeysInHashInspection
Instance Method Summary collapse
- #finish(response) ⇒ Object
-
#initialize(logger) ⇒ Request
constructor
A new instance of Request.
- #start(env) ⇒ Object
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..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 |