Class: Gitlab::Middleware::ActionControllerStaticContext
- Inherits:
-
Object
- Object
- Gitlab::Middleware::ActionControllerStaticContext
- Defined in:
- lib/gitlab/middleware/action_controller_static_context.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ ActionControllerStaticContext
constructor
A new instance of ActionControllerStaticContext.
Constructor Details
#initialize(app) ⇒ ActionControllerStaticContext
Returns a new instance of ActionControllerStaticContext.
6 7 8 |
# File 'lib/gitlab/middleware/action_controller_static_context.rb', line 6 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gitlab/middleware/action_controller_static_context.rb', line 10 def call(env) req = ActionDispatch::Request.new(env) action_name = req.path_parameters[:action] caller_id = req.controller_class.try(:endpoint_id_for_action, action_name) feature_category = req.controller_class.try(:feature_category_for_action, action_name).to_s context = {} context[:caller_id] = caller_id if caller_id context[:feature_category] = feature_category if feature_category.present? # We need to push the context here, so it persists after this middleware finishes # We need the values present in Labkit's rack middleware that surrounds this one. Gitlab::ApplicationContext.push(context) @app.call(env) end |