Welcome to mirror list, hosted at ThFree Co, Russian Federation.

request_context.rb « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 36a5d94d98ae238e5a4315e195c8a58294fcbfe0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module Gitlab
  class RequestStoreNotActive < StandardError
  end

  class RequestContext
    class << self
      def client_ip
        RequestStore[:client_ip]
      end
    end

    def initialize(app)
      @app = app
    end

    def call(env)
      raise RequestStoreNotActive.new unless RequestStore.active?
      req = Rack::Request.new(env)

      RequestStore[:client_ip] = req.ip

      @app.call(env)
    end
  end
end