lib/goliath/deprecated/async_aroundware.rb
# Put aroundware in the middle of the async_callback chain:
# * save the old callback chain;
# * have the downstream callback send results to the aroundware (possibly
#   completing it)
# * set the old callback chain to fire when the aroundware completes
Put aroundware in the middle of the async_callback chain:
save the old callback chain;
have the downstream callback send results to the aroundware (possibly
completing it)
set the old callback chain to fire when the aroundware completes
Put aroundware in the middle of the async_callback chain : save the old callback chain ; have the downstream callback send results to the aroundware ( possibly completing it ) set the old callback chain to fire when the aroundware completes
def hook_into_callback_chain(env, aroundware)
        async_callback = env['async.callback']
        downstream_callback = Proc.new do |resp|
          safely(env){ aroundware.call(resp) }
        end
        invoke_upstream_chain = Proc.new do
          new_resp = safely(env){ aroundware.post_process }
          async_callback.call(new_resp)
        end
        env['async.callback'] = downstream_callback
        aroundware.callback(&invoke_upstream_chain)
        aroundware.errback(&invoke_upstream_chain)
      end
def hook_into_callback_chain ( env , aroundware ) async_callback = env [ 'async.callback' ] downstream_callback = Proc . new do | resp | safely ( env ) { aroundware . call ( resp ) } end invoke_upstream_chain = Proc . new do new_resp = safely ( env ) { aroundware . post_process } async_callback . call ( new_resp ) end env [ 'async.callback' ] = downstream_callback aroundware . callback ( & invoke_upstream_chain ) aroundware . errback ( & invoke_upstream_chain ) end
Put aroundware in the middle of the async_callback chain:
 save the old callback chain;
 have the downstream callback send results to the aroundware (possibly
completing it)
 set the old callback chain to fire when the aroundware completes
Put aroundware in the middle of the async_callback chain : save the old callback chain ; have the downstream callback send results to the aroundware ( possibly completing it ) set the old callback chain to fire when the aroundware completes
# The response from the downstream app is accepted by the aroundware... # .. but the upstream chain is only invoked when the aroundware completes
env
aroundware