Created
December 1, 2016 15:55
-
-
Save dineshprabu-freshdesk/e2681b538da95e7b163e6eba3e63d786 to your computer and use it in GitHub Desktop.
[Ruby] Async HTTP request with Faraday and EM
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 characters
require 'em-http-request' | |
require 'faraday' | |
conn = Faraday.new "http://httpbin.org" do |con| | |
con.adapter :em_http | |
end | |
r = conn.get '/ip' | |
p r.finished? #For checking completion | |
#Run on completion | |
r.on_complete{ | |
p r.body | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment