Sha256: f4ddec1087b091525404e62ac3c60484352d3577a9298fec63acb2f73c18312f
Contents?: true
Size: 578 Bytes
Versions: 1
Compression:
Stored size: 578 Bytes
Contents
# frozen_string_literal: true module Vindi module Middleware # Saves the rate limts from Vindi responses. class RateLimitValidation < Faraday::Middleware def call(env) raise Vindi::RateLimitError, "Rate limit reached" if rate_limit_reached? @app.call(env) end private def rate_limit_reached? return false unless Vindi::RateLimit.rate_limit_limit Vindi::RateLimit.rate_limit_limit <= Vindi::RateLimit.rate_limit_remaining && Vindi::RateLimit.rate_limit_reset > Time.now end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rvindi-0.0.3 | lib/vindi/middleware/rate_limit_validation.rb |