Class: TCellAgent::Instrumentation::Rails::Middleware::GlobalMiddleware
- Inherits:
-
Object
- Object
- TCellAgent::Instrumentation::Rails::Middleware::GlobalMiddleware
- Defined in:
- lib/tcell_agent/rails/middleware/global_middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ GlobalMiddleware
constructor
A new instance of GlobalMiddleware.
Constructor Details
#initialize(app) ⇒ GlobalMiddleware
Returns a new instance of GlobalMiddleware.
20 21 22 |
# File 'lib/tcell_agent/rails/middleware/global_middleware.rb', line 20 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/tcell_agent/rails/middleware/global_middleware.rb', line 24 def call(env) if TCellAgent.configuration.should_intercept_requests? request = Rack::Request.new(env) TCellAgent::Instrumentation.safe_block('Setting session_id & user_id') do if request.session env[TCellAgent::Instrumentation::TCELL_ID].session_id = request.session['session_id'] env[TCellAgent::Instrumentation::TCELL_ID].user_id = TCellAgent::UserInformation.get_user_from_request(request) end end TCellAgent::Instrumentation.safe_block('Setting hmac_session_id') do if request.env[TCellAgent::Instrumentation::TCELL_ID].session_id env[TCellAgent::Instrumentation::TCELL_ID].hmac_session_id = TCellAgent::SensorEvents::Util.hmac(request.env[TCellAgent::Instrumentation::TCELL_ID].session_id) end end end @app.call(env) end |