summaryrefslogtreecommitdiff
path: root/lib/gitlab/request_context.rb
blob: fef536ecb0bf27092a4c05315017cd37c8e7d469 (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
        RequestStore[:client_ip]
      end
    end

    def initialize(app)
      @app = app
    end

    def call(env)
      req = Rack::Request.new(env)

      RequestStore[:client_ip] = req.ip

      @app.call(env)
    end
  end
end