Files
Dena/app/api/v2/constraints.rb
2026-08-13 19:50:53 +03:30

23 lines
546 B
Ruby

# encoding: UTF-8
# frozen_string_literal: true
module API
module V2
module Constraints
class << self
def included(base)
rate_limit = ENV.fetch("PEATIO_RATE_LIMIT_5MIN", 6000).to_i
apply_rules!(rate_limit)
base.use Rack::Attack
end
def apply_rules!(rate_limit)
Rack::Attack.throttle 'Limit number of calls to API', limit: rate_limit, period: 5.minutes do |req|
req.env['api_v2.authentic_member_email']
end
end
end
end
end
end