Module: Rack::Stream::DSL
- Defined in:
- lib/rack/stream/dsl.rb
Overview
DSL to access Rack::Stream::App methods.
Example
# config.ru
class App
include Rack::Stream::DSL
# declare your rack endpoint with a block
stream do
# all `Rack::Stream::App` methods, and `env` are available to you
chunk "Hello"
before_close { chunk "Bye" }
# return a rack response
[200, {'Content-Type' => 'text/plain'}, []]
end
end
run App.new
Rack Frameworks
If you mix this module into a class that already responds to #call
,
then you need to make env
available so that methods can be delegated to
env['rack.stream']
. There is no need to declare a stream
block in this case.
For example, Sinatra makes env
available to its endpoints:
class App < Sinatra::Base
include Rack::Stream::DSL
get '/' do
chunk "Hello" # no need to declare stream block b/c `env` is available
end
end
Defined Under Namespace
Modules: ClassMethods, InstanceMethods Classes: StreamBlockNotDefined