Sha256: 76429bbc41ff608ff01432ad4b6702c96968a1cbbdce38872862270dccf46ff0

Contents?: true

Size: 618 Bytes

Versions: 1

Compression:

Stored size: 618 Bytes

Contents

# frozen_string_literal: true

# @api experimental
module Phlex::Rails::Streaming
	private def stream(view)
		headers.delete("Content-Length")

		headers["X-Accel-Buffering"] = "no"
		headers["Cache-Control"] = "no-cache"
		headers["Content-Type"] = "text/html; charset=utf-8"
		headers["Last-Modified"] = Time.zone.now.ctime.to_s

		response.status = 200

		self.response_body = Enumerator.new do |buffer|
			view.call(buffer, view_context: view_context)
		rescue => e
			buffer << %('">)
			buffer << view_context.javascript_tag(nonce: true) { %(window.location = "/500.html").html_safe }

			raise e
		end
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
phlex-rails-0.10.0 lib/phlex/rails/streaming.rb