Sha256: 32a65dd0803e01f815d2e501986ea23fd302155af972aec9fe7e8cffc4d3db28
Contents?: true
Size: 574 Bytes
Versions: 2
Compression:
Stored size: 574 Bytes
Contents
# frozen_string_literal: true # Saves the rate limts from Vindi responses. module Vindi module Middleware 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vindi-hermes-0.0.2 | lib/vindi/middleware/rate_limit_validation.rb |
vindi-hermes-0.0.1 | lib/vindi/middleware/rate_limit_validation.rb |