mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 21:38:41 -05:00
Add http request method that takes user/password combo
This commit is contained in:
parent
4198321127
commit
607a679a81
2 changed files with 26 additions and 5 deletions
|
|
@ -15,4 +15,25 @@ class Http
|
|||
|
||||
return conn
|
||||
end
|
||||
|
||||
def self.get_conn(verbose, url, user, password)
|
||||
if url.nil?
|
||||
STDERR.puts "The url you provided was empty"
|
||||
exit 1
|
||||
end
|
||||
|
||||
if user.nil?
|
||||
STDERR.puts "You did not provide a user to authenticate with"
|
||||
exit 1
|
||||
end
|
||||
|
||||
conn = Faraday.new(:url => url) do |faraday|
|
||||
faraday.request :url_encoded
|
||||
faraday.request :basic_auth, user, password
|
||||
faraday.response :logger if verbose
|
||||
faraday.adapter Faraday.default_adapter
|
||||
end
|
||||
|
||||
return conn
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue