Last active
August 29, 2015 14:25
-
-
Save davidji99/b64b9b08b1a0acfa08a9 to your computer and use it in GitHub Desktop.
Revisions
-
amirrajan revised this gist
May 27, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ module HTTPStuff def self.post(path, payload) uri = construct_uri path http = Net::HTTP.new(uri.host, uri.port) req = Net::HTTP::Post.new(uri.path) req.body = payload.to_json -
amirrajan created this gist
Apr 12, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ module HTTPStuff def self.post(path, payload) uri = construct_uripath http = Net::HTTP.new(uri.host, uri.port) req = Net::HTTP::Post.new(uri.path) req.body = payload.to_json req["Authorization"] ='SOMEAUTH' req["Content-Type"] = "application/json" print http.request(req) end def self.construct_uri(path) return URI.parse("http://localhost:10000/" + path) end def self.get(path) uri = construct_uri path http = Net::HTTP.new(uri.host, uri.port) req = Net::HTTP::Get.new(uri.path) req["Authorization"] ='SOMEAUTH' print http.request(req) end def self.print(response) begin puts JSON.pretty_generate(JSON.parse(response.body)) rescue puts response end end end