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

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

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Logger

Returns a new instance of Logger.



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

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



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

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