Module: Async::WebSocket::Adapters::Rails

Defined in:
lib/async/websocket/adapters/rails.rb

Class Method Summary collapse

Class Method Details

.open(request, **options, &block) ⇒ Object


29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/async/websocket/adapters/rails.rb', line 29

def self.open(request, **options, &block)
	if response = Rack.open(request.env, **options, &block)
		response[1]['rack.hijack'] = lambda do |stream|
			response[2].call(stream)
		end
		
		# Close the response to prevent Rails from... trying to render a view?
		return ::ActionDispatch::Response.new(response[0], response[1], nil).tap(&:close)
	end
	
	return ::ActionDispatch::Response.new(404, [], [])
end