I currently have the following code:
if protocol == 'http'
port = Net::HTTP.http_default_port()
endpoint = Net::HTTP.new(host, port)
else
port = Net::HTTP.https_default_port()
endpoint = Net::HTTP.new(host, port)
endpoint.use_ssl = true
end
request = Net::HTTP::Get.new("/item/#{item}")
request['Authorization'] = "Bearer #{key}"
response = endpoint.request(request)
Is there a way to simplify this so that I do not have to decide the default port to use for myself?