class Rack::ApiKeyLimit::Hourly

Public Instance Methods

get_key(request, counter) click to toggle source
# File lib/rack_api_key_limit/hourly.rb, line 4
def get_key(request, counter)
  api_key = param(request)
  "#{param_name}-rate-limit:#{api_key}-#{Time.now.hour}"
end
limit_seconds() click to toggle source
# File lib/rack_api_key_limit/hourly.rb, line 9
def limit_seconds
  3600
end
retry_after() click to toggle source
# File lib/rack_api_key_limit/hourly.rb, line 13
def retry_after
  retry_after_seconds(Time.now, limit_seconds)        
end
retry_after_seconds(time_now, period_seconds) click to toggle source
# File lib/rack_api_key_limit/hourly.rb, line 17
def retry_after_seconds(time_now, period_seconds)
  seconds_since_midnight = time_now.to_i % 86400
  (period_seconds - seconds_since_midnight % period_seconds)
end