Class: Rack::Throttle::MethodMatcher

Inherits:
Matcher
  • Object
show all
Defined in:
lib/rack/throttle/matchers/method_matcher.rb

Overview

MethodMatchers are used to restrict throttling based on the HTTP method used by the request. For instance, you may only care about throttling POST requests on a login form; GET requests are just fine. MethodMatchers take Symbol objects of :get, :put, :post, or :delete

Instance Attribute Summary

Attributes inherited from Matcher

#rule

Instance Method Summary collapse

Methods inherited from Matcher

#initialize

Constructor Details

This class inherits a constructor from Rack::Throttle::Matcher

Instance Method Details

#identifierString

Returns:

  • (String)


19
20
21
# File 'lib/rack/throttle/matchers/method_matcher.rb', line 19

def identifier
  "meth-#{@rule}"
end

#match?(request) ⇒ Boolean

Parameters:

  • request (Rack::Request)

Returns:

  • (Boolean)


12
13
14
15
# File 'lib/rack/throttle/matchers/method_matcher.rb', line 12

def match?(request)
  rack_method = :"#{@rule}?"
  request.send(rack_method)
end