Ruby 机架中间件服务器崩溃
我试图编写如下简单的机架中间件:Ruby 机架中间件服务器崩溃,ruby,Ruby,我试图编写如下简单的机架中间件: class NewMiddleWare NEW_STRING = <<BEGIN my new content BEGIN def initialize(app) @app = app end def call(en
class NewMiddleWare
NEW_STRING = <<BEGIN
my new content
BEGIN
def initialize(app)
@app = app
end
def call(env)
status, headers, response = @app.call(env)
response_body = ""
response.each {|part| response_body += part}
response_body += "#{NEW_STRING}"
headers["Content-Length"] = response_body.length.to_s
[status, headers, response_body]
end
end
类新中间件
新字符串=来自:
正文必须对每个进行响应,并且只能产生字符串值。主体本身不应该是字符串的实例,因为这将在Ruby 1.9中中断
在Ruby 1.8中,字符串确实响应每个,但在1.9中有所改变
最简单的解决方案是只返回包含以下字符串的数组:
[status, headers, [response_body]]