Class: Upfluence::Utils::HTTP::Middleware::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/upfluence/utils/http/middleware/logger.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Logger



8
9
10
# File 'lib/upfluence/utils/http/middleware/logger.rb', line 8

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/upfluence/utils/http/middleware/logger.rb', line 12

def call(env)
  began_at = Time.now
  status, header, body = @app.call(env)
  header = Rack::Utils::HeaderHash.new(header)
  body = Rack::BodyProxy.new(body) { log(env, status, header, began_at) }
  [status, header, body]
end