Class: TallyCounter::Middleware
- Inherits:
-
Object
- Object
- TallyCounter::Middleware
- Defined in:
- lib/tally_counter.rb
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.
56 57 58 59 60 61 62 63 |
# File 'lib/tally_counter.rb', line 56 def initialize(app, = {}) @app = app @interval = [:interval] || 300 @logger = [:logger] || Logger.new($stdout) @namespace = [:namespace] @redis = [:redis] || Redis.current @timeout = [:timeout] || 0.007 end |
Instance Method Details
#call(env) ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/tally_counter.rb', line 65 def call(env) tuple = @app.call(env) unless tuple[1].delete('X-Tally-Counter-Skip') req = Rack::Request.new(env) track_ip(req.ip) end tuple end |