Module: Roda::RodaPlugins::Streaming::InstanceMethods
- Defined in:
- lib/roda/plugins/streaming.rb
Instance Method Summary collapse
-
#stream(opts = OPTS, &block) ⇒ Object
Immediately return a streaming response using the current response status and headers, calling the block to get the streaming response.
Instance Method Details
#stream(opts = OPTS, &block) ⇒ Object
Immediately return a streaming response using the current response status and headers, calling the block to get the streaming response. See Streaming for details.
156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/roda/plugins/streaming.rb', line 156 def stream(opts=OPTS, &block) opts = opts.merge(:scheduler=>EventMachine) if !opts.has_key?(:scheduler) && env['async.callback'] if opts[:loop] block = proc do |out| until out.closed? yield(out) end end end throw :halt, @_response.finish_with_body(Stream.new(opts, &block)) end |