gitlab-org--gitlab-foss/lib/gitlab/request_context.rb
Michael Kozono a54a5d9f39 Use Gitlab::SafeRequestStore in more places
Even if it doesn’t save lines of code, since people will tend to use
code they’ve seen. And `SafeRequestStore` is safer since you
don’t have to remember to check `RequestStore.active?`.
2018-09-24 12:11:27 -07:00

21 lines
335 B
Ruby

module Gitlab
class RequestContext
class << self
def client_ip
Gitlab::SafeRequestStore[:client_ip]
end
end
def initialize(app)
@app = app
end
def call(env)
req = Rack::Request.new(env)
Gitlab::SafeRequestStore[:client_ip] = req.ip
@app.call(env)
end
end
end