doing a request with basic auth

Developer from somewhere

1
2
3
4
5
6
7
8
require "net/http"

url = URI.parse('http://localhost:3000/users/1.json')
req = Net::HTTP::Get.new(url.path)
req.basic_auth 'user', 'pass'

resp = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
puts resp