debian-mirror-gitlab/lib/gitlab/middleware/request_context.rb

26 lines
686 B
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
module Gitlab
module Middleware
class RequestContext
def initialize(app)
@app = app
end
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)
2021-03-11 19:13:27 +05:30
::Gitlab::InstrumentationHelper.init_instrumentation_data(request_ip: req.ip)
2020-03-13 15:44:24 +05:30
@app.call(env)
end
end
end
end