Sha256: ec85c79103f69a29df585eae768aae5cebc4cf8e8758ef4f73e1833739b1f9ff

Contents?: true

Size: 597 Bytes

Versions: 6

Compression:

Stored size: 597 Bytes

Contents

# frozen_string_literal: true

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

        def bearer_auth(token)
          authentication("Bearer #{token}")
        end
      end
    end
    register_plugin :authentication, Authentication
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
httpx-0.24.7 lib/httpx/plugins/authentication.rb
httpx-0.24.6 lib/httpx/plugins/authentication.rb
httpx-0.24.5 lib/httpx/plugins/authentication.rb
httpx-0.24.4 lib/httpx/plugins/authentication.rb
httpx-0.24.3 lib/httpx/plugins/authentication.rb
httpx-0.24.2 lib/httpx/plugins/authentication.rb