Class: JSONAPI::Rack::N1Detection

Inherits:
Object
  • Object
show all
Defined in:
lib/json_api/rack/n1_detection.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ N1Detection

Returns a new instance of N1Detection.



8
9
10
# File 'lib/json_api/rack/n1_detection.rb', line 8

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/json_api/rack/n1_detection.rb', line 12

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