summaryrefslogtreecommitdiff
path: root/lib/gitlab/request_context.rb
blob: 8562d4515aa604f5dc31ef398ac9bbd32e3fb398 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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