class JSONAPI::Rack::N1Detection

def call(env)

def call(env)
  return @app.call(env) unless JSONAPI.configuration.n1_detection_enabled
  return @app.call(env) unless jsonapi_request?(env)
  return @app.call(env) unless postgres?
  Thread.current[:jpie_request_env] = env
  Prosopite.custom_logger = JSONAPI::Support::ProsopiteInstrumentationLogger.new
  result = Prosopite.scan { @app.call(env) }
  result
ensure
  Prosopite.finish
  Thread.current[:jpie_request_env] = nil
end

def initialize(app)

def initialize(app)
  @app = app
end

def jsonapi_request?(env)

def jsonapi_request?(env)
  env["HTTP_ACCEPT"].to_s.include?("application/vnd.api+json")
end

def postgres?

def postgres?
  return false unless defined?(ActiveRecord) && ActiveRecord::Base.connection_db_config
  adapter = ActiveRecord::Base.connection_db_config.adapter
  adapter.to_s.include?("postgresql")
end