Skip to content

Instantly share code, notes, and snippets.

@luckyruby
Created April 14, 2012 21:34
Show Gist options
  • Save luckyruby/2387988 to your computer and use it in GitHub Desktop.
Save luckyruby/2387988 to your computer and use it in GitHub Desktop.
def send_GET
url = 'http://somewebservice.com/api?foo=bar'
http = EventMachine::HttpRequest.new(URI url).get
http.callback {
operation = proc do
parsed_json = JSON.parse(http.response)
xml_response = convert_json_to_xml(parsed_json)
end
callback = proc do |r|
send_data r
close_connection_after_writing
end
EM.defer(operation, callback)
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment