Add http request method that takes user/password combo

This commit is contained in:
Brian Cain 2015-09-14 22:15:01 -07:00
parent 4198321127
commit 607a679a81
2 changed files with 26 additions and 5 deletions

View file

@ -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