Module: Ration::Rails::SSE
- Defined in:
- lib/ration/rails.rb
Instance Method Summary collapse
Instance Method Details
#sse_stream(&block) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/ration/rails.rb', line 7 def sse_stream(&block) response.headers['Content-Type'] = 'text/event-stream' response.headers['Cache-Control'] = 'no-cache' request.env['puma.mark_as_io_bound']&.call last_event_id = request.headers['Last-Event-ID'] self.response_body = Enumerator.new {|y| block.call(y, last_event_id) } end |