Module: HTTPX::Plugins::Auth::InstanceMethods

Defined in:
lib/httpx/plugins/auth.rb

Instance Method Summary collapse

Instance Method Details

#authorization(token = nil, auth_header_type: nil, &blk) ⇒ Object



51
52
53
# File 'lib/httpx/plugins/auth.rb', line 51

def authorization(token = nil, auth_header_type: nil, &blk)
  with(auth_header_type: auth_header_type, auth_header_value: token || blk)
end

#bearer_auth(token = nil, &blk) ⇒ Object



55
56
57
# File 'lib/httpx/plugins/auth.rb', line 55

def bearer_auth(token = nil, &blk)
  authorization(token, auth_header_type: "Bearer", &blk)
end

#initializeObject



43
44
45
46
47
48
49
# File 'lib/httpx/plugins/auth.rb', line 43

def initialize(*)
  super

  @auth_header_value = nil
  @auth_header_value_mtx = Thread::Mutex.new
  @skip_auth_header_value = false
end

#reset_auth_header_value!Object



66
67
68
69
70
# File 'lib/httpx/plugins/auth.rb', line 66

def reset_auth_header_value!
  @auth_header_value_mtx.synchronize do
    @auth_header_value = nil
  end
end

#skip_auth_headerObject



59
60
61
62
63
64
# File 'lib/httpx/plugins/auth.rb', line 59

def skip_auth_header
  @skip_auth_header_value = true
  yield
ensure
  @skip_auth_header_value = false
end