Sha256: efb45a3ee5f5fc9a07db2f5399d7992b2d41b890d9dcf6ec3190dffaa214c56e

Contents?: true

Size: 633 Bytes

Versions: 7

Compression:

Stored size: 633 Bytes

Contents

# frozen_string_literal: true

module HTTPX
  module Plugins
    #
    # This plugin adds a shim +authorization+ method to the session, which will fill
    # the HTTP Authorization header, and another, +bearer_auth+, which fill the "Bearer " prefix
    # in its value.
    #
    # https://gitlab.com/os85/httpx/wikis/Auth#authorization
    #
    module Auth
      module InstanceMethods
        def authorization(token)
          with(headers: { "authorization" => token })
        end

        def bearer_auth(token)
          authorization("Bearer #{token}")
        end
      end
    end
    register_plugin :auth, Auth
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
httpx-1.1.3 lib/httpx/plugins/auth.rb
httpx-1.1.2 lib/httpx/plugins/auth.rb
httpx-1.1.1 lib/httpx/plugins/auth.rb
httpx-1.1.0 lib/httpx/plugins/auth.rb
httpx-1.0.2 lib/httpx/plugins/auth.rb
httpx-1.0.1 lib/httpx/plugins/auth.rb
httpx-1.0.0 lib/httpx/plugins/auth.rb