Class: ActiveAccess::Middleware
- Inherits:
-
Object
- Object
- ActiveAccess::Middleware
- Defined in:
- lib/active-access/middleware.rb
Constant Summary collapse
- WHITELISTED_IPS =
Set.new
Class Method Summary collapse
Instance Method Summary collapse
- #call(rack_request) ⇒ Object
-
#initialize(app, handler = {}) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, handler = {}) ⇒ Middleware
Returns a new instance of Middleware.
15 16 17 18 19 |
# File 'lib/active-access/middleware.rb', line 15 def initialize(app, handler = {}) @app = app @handler = handler refresh_whitelisted_ips end |
Class Method Details
.allow_ip!(addr) ⇒ Object
11 12 13 |
# File 'lib/active-access/middleware.rb', line 11 def self.allow_ip!(addr) WHITELISTED_IPS << IPAddr.new(addr) end |
Instance Method Details
#call(rack_request) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/active-access/middleware.rb', line 21 def call(rack_request) if allow?(rack_request) @app.call(rack_request) else [404, { "Content-Type" => "text/html", "Content-Length" => config..length.to_s }, [config.]] end end |