Skip to content

Latest commit

 

History

History
54 lines (36 loc) · 1.11 KB

README.md

File metadata and controls

54 lines (36 loc) · 1.11 KB

RealIp

Rack middleware to get client IP address on Heroku, extracted from our API service.

Installation

Add this line to your application's Gemfile:

gem 'real_ip', github: 'quipper/real_ip'

And then execute:

$ bundle

Or install it yourself as:

$ gem install real_ip

Usage

  1. Mount RealIp rack middleware at the top of your Rack application's middleware stack.

Rack (config.ru)

require 'real_ip'
use RealIp

Rails (config/application.rb or config/environments/*.rb)

module MyApp
  class Application < Rails::Application
    config.middleware.insert 0, 'RealIp'
  end
end

MyApp::Application.configure do
  config.middleware.insert 0, 'RealIp'
end
  1. On your controller, use request.env['QUIPPER_REMOTE_ADDR'] to get the IP address

Contributing

  1. Fork it ( https://github.com/[my-github-username]/real_ip/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request