Module: Kernel
- Defined in:
- lib/api_pi/request.rb
Instance Method Summary collapse
-
#get(url, &block) ⇒ Object
Patch to add the ‘get` method.
-
#set_header(key, value) ⇒ Object
Used to set headers for GET requests.
Instance Method Details
#get(url, &block) ⇒ Object
Patch to add the ‘get` method. Create tests and assertions within.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/api_pi/request.rb', line 8 def get url, &block uri = URI.parse url get = Net::HTTP::Get.new(uri) req = Net::HTTPHeader.build_headers get http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = (uri.scheme == 'https') resp = http.request req json = net_parse resp ApiPi::Dsl.new(json).parse(url, block) end |