2018-10-22 07:00:50 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-02-06 12:48:46 +00:00
|
|
|
module Gitlab
|
|
|
|
class RequestContext
|
|
|
|
class << self
|
|
|
|
def client_ip
|
2018-09-20 22:40:15 +00:00
|
|
|
Gitlab::SafeRequestStore[:client_ip]
|
2017-02-06 12:48:46 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def initialize(app)
|
|
|
|
@app = app
|
|
|
|
end
|
|
|
|
|
|
|
|
def call(env)
|
|
|
|
req = Rack::Request.new(env)
|
|
|
|
|
2018-09-20 22:40:15 +00:00
|
|
|
Gitlab::SafeRequestStore[:client_ip] = req.ip
|
2017-02-06 12:48:46 +00:00
|
|
|
|
|
|
|
@app.call(env)
|
|
|
|
end
|
|
|
|
end
|
2017-02-16 10:21:30 +00:00
|
|
|
end
|