Sha256: 7e003bb5a28dd1ef95d113e496c7e0df2550b4b2353e65c962f40d3a187603eb
Contents?: true
Size: 762 Bytes
Versions: 33
Compression:
Stored size: 762 Bytes
Contents
require 'faraday/middleware' require 'zendesk_api/error' module ZendeskAPI module Middleware # @private module Request # Faraday middleware to handle HTTP Status 429 (rate limiting) / 503 (maintenance) # @private class RaiseRateLimited < Faraday::Middleware ERROR_CODES = [429, 503].freeze def initialize(app, options = {}) super(app) @logger = options[:logger] end def call(env) response = @app.call(env) if ERROR_CODES.include?(response.env[:status]) @logger&.warn 'You have been rate limited. Raising error...' raise Error::RateLimited, env else response end end end end end end
Version data entries
33 entries across 33 versions & 2 rubygems