Sha256: 674828183f4978201c096399118d5d7423e2b0d7e01acb88f322ada4598e27aa
Contents?: true
Size: 993 Bytes
Versions: 1
Compression:
Stored size: 993 Bytes
Contents
# frozen_string_literal: true module ErpIntegration module Middleware # The {Formatter} class is a custom formatter for the Faraday logger. # It logs the rate limiter headers in the response. class Formatter < Faraday::Logging::Formatter def response(env) super public_send(log_level, 'response', &rate_limiter_headers(env.response_headers)) end # Formats the rate limiter headers. # @param headers [Hash] def rate_limiter_headers(headers) proc do [ limit(headers), remaining(headers), reset_at(headers) ].join(', ') end end def limit(headers) "Rate Limit #{headers['x-ratelimit-limit']}" end def remaining(headers) "Remaining Limit #{headers['x-ratelimit-remaining']}" end def reset_at(headers) "Rate Limit Reset at #{Time.at(headers['x-ratelimit-reset'].to_i).utc}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
erp_integration-0.57.0 | lib/erp_integration/middleware/formatter.rb |