Sha256: ad4225462cdd6d83f8ef941847969dd88e1f52ed1b8d86bf441ff595f55737db

Contents?: true

Size: 433 Bytes

Versions: 2

Compression:

Stored size: 433 Bytes

Contents

require 'rack/congestion'

# Limit requests to
#   - a maximum of 10 requests per minute to /api
#   - a maximum of 5 requests per minute to everything else
use Rack::Congestion::PathLimiter, path: 'api', interval: 60,
  max_in_interval: 10

use Rack::Congestion::PathLimiter, path: 'other', interval: 60,
  max_in_interval: 5, path_matcher: /^\/(?!api)/i

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/per_path.ru
rack-congestion-0.0.2 examples/per_path.ru