class IpAnonymizer::HashIp

Public Class Methods

new(app, key:) click to toggle source
# File lib/ip_anonymizer/hash_ip.rb, line 3
def initialize(app, key:)
  @app = app
  @key = key
end

Public Instance Methods

call(env) click to toggle source
# File lib/ip_anonymizer/hash_ip.rb, line 8
def call(env)
  req = ActionDispatch::Request.new(env)
  # get header directly to preserve ActionDispatch::RemoteIp lazy loading
  req.remote_ip = GetIp.new(req.get_header("action_dispatch.remote_ip".freeze), @key)
  @app.call(req.env)
end