Sha256: 5cbf9db43ad96059358159f75bfbebb4a11fa3eb18eb567df996498968d6af78

Contents?: true

Size: 360 Bytes

Versions: 2

Compression:

Stored size: 360 Bytes

Contents

require 'rack/congestion'

class CustomLimiter < Rack::Congestion::PathLimiter
  def key
    ->{ "#{ request.ip }-#{ path }" }
  end
end

# Limit requests to
#   - a maximum of 10 requests per minute per user to /api
use CustomLimiter, path: 'api', interval: 60, max_in_interval: 10

run ->(env){
  [200, { 'Content-Type' => 'text/plain' }, ['Hello world']]
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rack-congestion-0.0.3 examples/custom.ru
rack-congestion-0.0.2 examples/custom.ru