Sha256: 7ea51383dc29054d92804b0ba235bcbd76127d7ccb03e2c96c03df45e52f5df2

Contents?: true

Size: 624 Bytes

Versions: 13

Compression:

Stored size: 624 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#auth
    #
    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

13 entries across 13 versions & 1 rubygems

Version Path
httpx-1.3.4 lib/httpx/plugins/auth.rb
httpx-1.3.3 lib/httpx/plugins/auth.rb
httpx-1.3.2 lib/httpx/plugins/auth.rb
httpx-1.3.1 lib/httpx/plugins/auth.rb
httpx-1.3.0 lib/httpx/plugins/auth.rb
httpx-1.2.6 lib/httpx/plugins/auth.rb
httpx-1.2.4 lib/httpx/plugins/auth.rb
httpx-1.2.3 lib/httpx/plugins/auth.rb
httpx-1.2.2 lib/httpx/plugins/auth.rb
httpx-1.2.1 lib/httpx/plugins/auth.rb
httpx-1.2.0 lib/httpx/plugins/auth.rb
httpx-1.1.5 lib/httpx/plugins/auth.rb
httpx-1.1.4 lib/httpx/plugins/auth.rb