Class: Gitlab::Middleware::RequestContext

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/middleware/request_context.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ RequestContext

Returns a new instance of RequestContext.


6
7
8
# File 'lib/gitlab/middleware/request_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
# File 'lib/gitlab/middleware/request_context.rb', line 10

def call(env)
  # We should be using ActionDispatch::Request instead of
  # Rack::Request to be consistent with Rails, but due to a Rails
  # bug described in
  # https://gitlab.com/gitlab-org/gitlab-foss/issues/58573#note_149799010
  # hosts behind a load balancer will only see 127.0.0.1 for the
  # load balancer's IP.
  req = Rack::Request.new(env)

  ::Gitlab::InstrumentationHelper.init_instrumentation_data(request_ip: req.ip)

  @app.call(env)
end