class Redshift::Rails::Middleware

Public Class Methods

new(app) click to toggle source
# File lib/redshift/rails/middleware.rb, line 4
def initialize(app)
  @app = app
end

Public Instance Methods

call(env) click to toggle source
# File lib/redshift/rails/middleware.rb, line 8
def call(env)
  testing = env['rack.test']

  response = @app.call(env)
  response[2] = ::Rack::BodyProxy.new(response[2]) do
    Redshift::Client.disconnect unless testing
  end

  response
rescue Exception
  Redshift::Client.disconnect unless testing
  raise
end