class Depthcharge::Middleware

Attributes

app[R]
outputs[R]

Public Class Methods

new(app, *outputs) click to toggle source
# File lib/depthcharge/middleware.rb, line 6
def initialize(app, *outputs)
  @app = app
  @outputs = outputs.flatten.map do |output|
    if output.is_a?(String) || output.is_a?(Pathname)
      File.open(output, "w")
    else
      output
    end
  end
end

Public Instance Methods

call(env) click to toggle source
# File lib/depthcharge/middleware.rb, line 17
def call(env)
  status, headers, body = @app.call(env)
  RequestLogger.new(env, status, headers, body).log(outputs)
  [status, headers, body]
end