Sha256: 1fb76c5cbd4cfa95d953b3d909b1088dbf6937e46d629fc0ae635593272e03b1

Contents?: true

Size: 861 Bytes

Versions: 9

Compression:

Stored size: 861 Bytes

Contents

id = '4'
times = 10

require 'async-rack'
require 'rest-graph'

use Rack::ContentType
use Rack::Reloader

module RG
  module_function
  def create env
    RestGraph.new(:log_method => env['rack.logger'].method(:debug))
  end
end

run Rack::Builder.new{
  map('/async'){
    run lambda{ |env|
      RG.create(env).multi([[:get, id]] * times){ |r|
        env['async.callback'].call [200, {}, r.map(&:inspect)]
      }
      throw :async
    }
  }
  map('/sync'){
    run lambda{ |env|
      [200, {}, (0...times).map{ RG.create(env).get(id) }.map(&:inspect)]
    }
  }
  map('/'){
    run lambda{ |env|
      [200, {'Content-Type' => 'text/html'},
        [<<-HTML
<html><body>
  go to <a href="/async">/async</a> for em-http-request (multi) result,<br/>
  go to <a href="/sync">/sync</a> for rest-client result.<br/>
</body></html>
HTML
        ]]
    }
  }
}

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rest-graph-2.0.3 example/multi/config.ru
rest-graph-2.0.2 example/multi/config.ru
rest-graph-2.0.1 example/multi/config.ru
rest-graph-2.0.0 example/multi/config.ru
rest-graph-1.9.1 example/multi/config.ru
rest-graph-1.9.0 example/multi/config.ru
rest-graph-1.8.0 example/multi/config.ru
rest-graph-1.7.0 example/multi/config.ru
rest-graph-1.6.0 example/multi/config.ru