Reputation: 7654
a classic hello world example from their doc,
class HelloWorld
def call(env)
return [200, {}, ["Hello world!"]]
end
end
my question is why the third value is [Hello world!"], not "Hello world"? From their doc,
The Body must respond to each and must only yield String values. The Body itself should not be an instance of String, as this will break in Ruby 1.9.
Why body needs to respond to each? and in what case does it matter?
Upvotes: 24
Views: 4642
Reputation: 66837
Judging from the sentence The Body itself should not be an instance of String, as this will break in Ruby 1.9.
, I'd assume that the last element of the response has to be an Enumerable
. Since String
s stopped including this module in 1.9, you'll need some sort of collection that implements it.
BTW: hello world examples are often not great for figuring out why something is done in a certain way, they are too trivial.
Upvotes: 7
Reputation: 686
I think rack originated on python's wsgi. Here is the explanation for python: http://www.python.org/dev/peps/pep-3333/#buffering-and-streaming
Upvotes: 11