rack-attack/lib/rack/attack/railtie.rb
Gonzalo Rodriguez e3056e737f
fix: avoid unintended effects on load_config_initializers and other gems load order
Because of the sort algorithm rails uses to satisfy `after` and `before`
constraints, gems can have unintended effects on others. See
0a120a818d

Prefer making rack-attack middleware idempotent instead of relying on
the load order and the contents of the middleware stack too much.

closes #452
closes #456
2019-10-29 15:45:26 -03:00

13 lines
311 B
Ruby

# frozen_string_literal: true
module Rack
class Attack
class Railtie < ::Rails::Railtie
initializer "rack-attack.middleware" do |app|
if Gem::Version.new(::Rails::VERSION::STRING) >= Gem::Version.new("5.1")
app.middleware.use(Rack::Attack)
end
end
end
end
end