Sha256: 3e53fdc89bcfd80e7a74e02c7f6a210b56e6b0e70e9f421d36b1a0f443396225

Contents?: true

Size: 594 Bytes

Versions: 1

Compression:

Stored size: 594 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?, :blocklisted?, :safelisted?

    def self.throttled_response
      Rack::Attack.throttled_response
    end

    def self.blacklisted_response
      Rack::Attack.blacklisted_response
    end

    def self.blocklisted_response
      Rack::Attack.blocklisted_response
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ahoy_matey-1.5.1 lib/ahoy/throttle.rb