Sha256: 9bb4bc293e8236563b154c8c311b10c29248a63c01103bcde47d32ebd0673832

Contents?: true

Size: 399 Bytes

Versions: 5

Compression:

Stored size: 399 Bytes

Contents

require "rack/attack"

module Ahoy
  class Throttle < Rack::Attack
    throttle("ahoy/ip", limit: Ahoy.throttle_limit, period: Ahoy.throttle_period) do |req|
      if req.path.start_with?("/ahoy/")
        req.ip
      end
    end

    def_delegators self, :whitelisted?, :blacklisted?, :throttled?, :tracked?

    def self.throttled_response
      Rack::Attack.throttled_response
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ahoy_matey-1.4.2 lib/ahoy/throttle.rb
ahoy_matey-1.4.1 lib/ahoy/throttle.rb
ahoy_matey-1.4.0 lib/ahoy/throttle.rb
ahoy_matey-1.3.1 lib/ahoy/throttle.rb
ahoy_matey-1.3.0 lib/ahoy/throttle.rb