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

24 lines
366 B
Ruby
Raw Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
module Gitlab
class RequestContext
class << self
def client_ip
2018-12-05 23:21:45 +05:30
Gitlab::SafeRequestStore[:client_ip]
2017-08-17 22:00:37 +05:30
end
end
def initialize(app)
@app = app
end
def call(env)
req = Rack::Request.new(env)
2018-12-05 23:21:45 +05:30
Gitlab::SafeRequestStore[:client_ip] = req.ip
2017-08-17 22:00:37 +05:30
@app.call(env)
end
end
end