Class: Rack::Throttle::UserAgentMatcher
- Defined in:
- lib/rack/throttle/matchers/user_agent_matcher.rb
Overview
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.
Instance Attribute Summary
Attributes inherited from Matcher
Instance Method Summary collapse
Methods inherited from Matcher
Constructor Details
This class inherits a constructor from Rack::Throttle::Matcher
Instance Method Details
#identifier ⇒ String
18 19 20 |
# File 'lib/rack/throttle/matchers/user_agent_matcher.rb', line 18 def identifier "ua-" + @rule.inspect end |
#match?(request) ⇒ Boolean
12 13 14 |
# File 'lib/rack/throttle/matchers/user_agent_matcher.rb', line 12 def match?(request) !!(@rule =~ request.user_agent) end |