Class: Rack::Attack

Inherits:
Object
  • Object
show all
Defined in:
lib/nexaas/throttle/middleware.rb

Class Method Summary collapse

Class Method Details

.configurationObject



6
7
8
# File 'lib/nexaas/throttle/middleware.rb', line 6

def self.configuration
  @configuration ||= Nexaas::Throttle.configuration
end

.guardian(request) ⇒ Object



10
11
12
# File 'lib/nexaas/throttle/middleware.rb', line 10

def self.guardian(request)
  Nexaas::Throttle::Guardian.new(request, configuration)
end

.throttled?(req) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
# File 'lib/nexaas/throttle/middleware.rb', line 14

def self.throttled?(req)
  throttled = throttles.any? do |name, throttle|
    throttle[req]
  end

  throttled && configuration.throttleable?
end