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