Sha256: d32f60601e083eb854469a6b8b2e5701218888f25970d2edbf34b867e248224e

Contents?: true

Size: 608 Bytes

Versions: 4

Compression:

Stored size: 608 Bytes

Contents

module Rack; module Throttle
  ###
  # User Agent Matchers are used to restrict requests based on the User
  # Agent supplied by the requester. For instance, you may care about
  # limiting a specific API consumer who reliably uses a known User-Agent.
  # UserAgentMatchers take Regexp objects to match against the
  # User-Agent.
  class UserAgentMatcher < Matcher
    ###
    # @param [Rack::Request] request
    # @return [Boolean]
    def match?(request)
      !!(@rule =~ request.user_agent)
    end

    ###
    # @return [String]
    def identifier
      "ua-" + @rule.inspect
    end
  end

end; end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
improved-rack-throttle-0.9.0 lib/rack/throttle/matchers/user_agent_matcher.rb
improved-rack-throttle-0.8.0 lib/rack/throttle/matchers/user_agent_matcher.rb
improved-rack-throttle-w-expiry-0.8.0 lib/rack/throttle/matchers/user_agent_matcher.rb
improved-rack-throttle-0.7.1 lib/rack/throttle/matchers/user_agent_matcher.rb