lostisland/faraday

Ability to pass a callable to authorization middleware

Closed this issue ยท 2 comments

sled commented

The authorization middleware currently checks for a Proc:

value = value.call if value.is_a?(Proc)

Wouldn't it make sense to ease this restriction and just require a callable?

Example use case:

class ComplexAuthorizer
  def call
     # do magic and return a token
  end
end

authorizer = ComplexAuthorizer.new(....)

Faraday.new(url: ....) do |conn|
  conn.request :authorization, 'Bearer', authorizer
end

That would make sense indeed, I'd happily review a PR that enhances the middleware to accept either a proc or a callable ๐Ÿ‘

sled commented

That would make sense indeed, I'd happily review a PR that enhances the middleware to accept either a proc or a callable ๐Ÿ‘

Here you go: #1345