Class: Rack::Throttle::UrlMatcher
- Defined in:
- lib/rack/throttle/matchers/url_matcher.rb
Overview
UrlMatchers are used to restrict requests based on the URL requested. For instance, you may care about limiting requests to a machine-consumed API, but not be concerned about requests coming from browsers. UrlMatchers take Regexp object to match against the request path.
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/url_matcher.rb', line 18 def identifier "url-" + @rule.inspect end |
#match?(request) ⇒ Boolean
12 13 14 |
# File 'lib/rack/throttle/matchers/url_matcher.rb', line 12 def match?(request) !!(@rule =~ request.path) end |