Class: RedisKnock::Middleware
- Inherits:
-
Object
- Object
- RedisKnock::Middleware
- Defined in:
- lib/redis_knock/middleware.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, options = {}) ⇒ Middleware
Returns a new instance of Middleware.
7 8 9 |
# File 'lib/redis_knock/middleware.rb', line 7 def initialize(app, = {}) @app, @options = app, end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
5 6 7 |
# File 'lib/redis_knock/middleware.rb', line 5 def app @app end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/redis_knock/middleware.rb', line 5 def @options end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 |
# File 'lib/redis_knock/middleware.rb', line 11 def call(env) request = Rack::Request.new env control = RedisKnock::Control.new control.allowed?(request) ? app.call(env) : limit_exceeded end |