Class: Sinatra::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/homura/runtime/stream.rb

Instance Method Summary collapse

Instance Method Details

#stream(keep_open = false, &block) ⇒ Object

Re-open to override. We keep the signature compatible with upstream (‘stream(keep_open = false, &block)`) but internally route through Cloudflare::SSEStream. Upstream’s ‘Stream` class is not used on Workers (no EventMachine / Thread pool).



312
313
314
315
316
317
318
319
320
321
# File 'lib/homura/runtime/stream.rb', line 312

def stream(keep_open = false, &block)
  ctx = env["cloudflare.ctx"]
  ::Cloudflare::SSEStream.new(
    headers: {
      "content-type" => "text/plain; charset=utf-8"
    },
    ctx: ctx,
    &block
  )
end