Class: IpRestriction::Middleware
- Inherits:
-
Object
- Object
- IpRestriction::Middleware
- Defined in:
- lib/ip_restriction/middleware.rb
Defined Under Namespace
Classes: Constraint
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
5 6 7 |
# File 'lib/ip_restriction/middleware.rb', line 5 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/ip_restriction/middleware.rb', line 9 def call(env) constraint = Constraint.instance if constraint.checker.allowed?(env["REMOTE_ADDR"]) @app.call(env) else [404, {'Content-Type' => 'text/html'}, ['Not found!']] end end |