class Routemaster::Middleware::Filter

Filters event payloads passed in the environment (in ‘env`), is any.

Will use ‘Routemaster::Dirty::Filter` by default.

Public Class Methods

new(app, options = {}) click to toggle source

options [Routemaster::Dirty::Filter] an event filter (optional; will be created using the ‘redis` and `expiry` options if not provided)

# File lib/routemaster/middleware/filter.rb, line 12
def initialize(app, options = {})
  @app    = app
  @filter = options.fetch(:filter) { Routemaster::Dirty::Filter.new }
end

Public Instance Methods

call(env) click to toggle source
# File lib/routemaster/middleware/filter.rb, line 17
def call(env)
  payload = env['routemaster.payload']
  if payload && payload.any?
    env['routemaster.payload'] = @filter.run(payload)
  end
  @app.call(env)
end