Sha256: bb6af2b7cb7a9db45dc72ee246a04940fd5fb4270acbc92fc075487fb035887a

Contents?: true

Size: 435 Bytes

Versions: 2

Compression:

Stored size: 435 Bytes

Contents

module ServiceDowntimeSimulator
  class Middleware
    def initialize(app, config)
      @app = app
      @config = ServiceDowntimeSimulator::Config.for(config)
    end

    def call(env)
      return app.call(env) if bypass?(env)

      config.mode_klass.new(app).call(env)
    end

    private

    attr_reader :app, :config

    def bypass?(env)
      !config.activated? || config.path_excluded?(env['PATH_INFO'])
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
service_downtime_simulator-0.1.1 lib/service_downtime_simulator/middleware.rb
service_downtime_simulator-0.1.0 lib/service_downtime_simulator/middleware.rb