require 'goliath' class Server < Goliath::API def response(env) case env['REQUEST_PATH'] when /index/ then [200, {}, IO.read('index.html')] when /stream/ then EM.add_periodic_timer(3) do env.stream_send("data event! ... ") end headers = {'Content-Type' => 'application/x-javascript'} [200, headers, Goliath::Response::STREAMING] end end end