Sha256: c9a61bf862827c4d396e090d78adc80b0c07ebc8abe966777ca627d20394cc1e
Contents?: true
Size: 780 Bytes
Versions: 1
Compression:
Stored size: 780 Bytes
Contents
# frozen_string_literal: true # IronBank main module module IronBank # IronBank Faraday middleware module module FaradayMiddleware # This middleware reauthorize the request on unauthorized request class RetriableAuth < Faraday::Middleware def initialize(app, auth) @auth = auth super(app) end def call(env) @env = env renew_auth_header if env.status == 401 @app.call(env) end private attr_reader :auth, :env def renew_auth_header auth.renew_session # The :retry middleware use cached request's headers which doesn't retry # the request headers automatically env.request_headers = env.request_headers.merge(auth.header) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
iron_bank-1.0.3 | lib/iron_bank/faraday_middleware/retriable_auth.rb |