Class: Rack::Entrance
- Inherits:
-
Object
- Object
- Rack::Entrance
- Defined in:
- lib/rack/entrance.rb,
lib/rack/entrance/version.rb
Defined Under Namespace
Modules: VERSION
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Entrance
constructor
A new instance of Entrance.
- #internal?(ip) ⇒ Boolean
- #internal_ips ⇒ Object
Constructor Details
#initialize(app, options = {}) ⇒ Entrance
Returns a new instance of Entrance.
6 7 8 |
# File 'lib/rack/entrance.rb', line 6 def initialize(app, = {}) @app = app end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/rack/entrance.rb', line 10 def call(env) request = Rack::Request.new(env) ip = env["action_dispatch.remote_ip"] || request.ip request.env['entrance.internal'] = internal? ip @app.call env end |
#internal?(ip) ⇒ Boolean
17 18 19 |
# File 'lib/rack/entrance.rb', line 17 def internal?(ip) internal_ips.include? ip end |
#internal_ips ⇒ Object
21 22 23 |
# File 'lib/rack/entrance.rb', line 21 def internal_ips @internal_ips ||= ENV['ENTRANCE_INTERNAL_IPS'].to_s.split(',') end |