examples/stream.rb in reel-0.3.0 vs examples/stream.rb in reel-0.4.0.pre

- old
+ new

@@ -1,26 +1,28 @@ require 'rubygems' require 'bundler/setup' require 'reel' +require 'reel/app' -app = Rack::Builder.new do - map '/' do - run lambda { |env| - body = Reel::Stream.new do |body| - # sending a payload to make sure browsers will render chunks as received - body << "<html>#{' '*1024}\n" - ('A'..'Z').each do |l| - body << "<div>#{l}</div>\n" - sleep 0.5 - end - body << "</html>\n" - body.finish +class Streamer + include Reel::App + + get '/' do + body = Reel::Stream.new do |body| + # sending a payload to make sure browsers will render chunks as received + body << "<html>#{' '*1024}\n" + ('A'..'Z').each do |l| + body << "<div>#{l}</div>\n" + sleep 0.5 end - [200, { - 'Transfer-Encoding' => 'identity', - 'Content-Type' => 'text/html' - }, body] - } + body << "</html>\n" + body.finish + end + [200, { + 'Transfer-Encoding' => 'identity', + 'Content-Type' => 'text/html' + }, body] end -end.to_app +end -Rack::Handler::Reel.run app, Port: 9292 +Streamer.new("0.0.0.0", 9292) +sleep