Konstantin Haase - cloudfront.net

Report 3 Downloads 77 Views
Real Time Rack Konstantin Haase

Come again? streaming server push

decide what to send while streaming, not upfront

Streaming APIs Server-Sent Events Websockets

Demo!

Rack Ruby to HTTP to Ruby bridge Middleware API Powers Rails, Sinatra, Ramaze, ...

welcome_app = proc do |env| [200, {'Content-Type' => 'text/html'}, ['Welcome!']] end

welcome_app = Object.new def welcome_app.call(env) [200, {'Content-Type' => 'text/html'}, ['Welcome!']] end

get('/') { 'Welcome!' }

env = parse_http status, headers, body = welcome_app.call env io.puts "HTTP/1.1 #{status}" headers.each { |k,v| io.puts "#{k}: #{v}" } io.puts "" body.each { |str| io.puts str } close_connection

Middleware

#

foo

=>

FOO

class UpperCase def initialize(app) @app = app end def call(env) status, headers, body = @app.call(env) upper = [] body.each { |s| upper