Skip to content

Ability to pass a callable to authorization middleware #1344

@sled

Description

@sled

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions