Sha256: 33a867538d0823eac5729c5cda9ab624922604c48081a744a62abba716f2575d

Contents?: true

Size: 617 Bytes

Versions: 4

Compression:

Stored size: 617 Bytes

Contents

module Rack; module Throttle
  ###
  # 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
  class MethodMatcher < Matcher
    ##
    # @param [Rack::Request] request
    # @return [Boolean]
    def match?(request)
      rack_method = :"#{@rule}?"
      request.send(rack_method)
    end

    ##
    # @return [String]
    def identifier
      "meth-#{@rule}"
    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/method_matcher.rb
improved-rack-throttle-0.8.0 lib/rack/throttle/matchers/method_matcher.rb
improved-rack-throttle-w-expiry-0.8.0 lib/rack/throttle/matchers/method_matcher.rb
improved-rack-throttle-0.7.1 lib/rack/throttle/matchers/method_matcher.rb