mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-03-25 09:25:49 +00:00
22 lines
440 B
Ruby
22 lines
440 B
Ruby
module Rack
|
|
module Attack
|
|
class Check
|
|
attr_reader :name, :block, :type
|
|
def initialize(name, block)
|
|
@name, @block = name, block
|
|
@type = nil
|
|
end
|
|
|
|
def [](req)
|
|
block[req].tap {|match|
|
|
if match
|
|
Rack::Attack.instrument(:type => type, :name => name, :request => req)
|
|
req.env["rack.attack.#{type}"] = name
|
|
end
|
|
}
|
|
end
|
|
|
|
end
|
|
end
|
|
end
|
|
|