examples/async_aroundware_demo.rb in goliath-0.9.4 vs examples/async_aroundware_demo.rb in goliath-1.0.0.beta.1
- old
+ new
@@ -1,11 +1,11 @@
#!/usr/bin/env ruby
$: << File.dirname(__FILE__)+'/../lib'
require 'goliath'
require 'em-synchrony/em-http'
-require 'yajl/json_gem'
+require 'yajl/json_gem' if RUBY_PLATFORM != 'java'
#
# Here's a way to make an asynchronous request in the middleware, and only
# proceed with the response when both the endpoint and our middleware's
# responses have completed.
@@ -43,10 +43,10 @@
BASE_URL = 'http://localhost:9002/'
class RemoteRequestBarrier
include Goliath::Rack::BarrierAroundware
attr_accessor :sleep_1
-
+
def pre_process
# Request with delay_1 and drop_1 -- note: 'aget', because we want execution to continue
req = EM::HttpRequest.new(BASE_URL).aget(:query => { :delay => env.params['delay_1'], :drop => env.params['drop_1'] })
enqueue :sleep_1, req
return Goliath::Connection::AsyncResponse