i want to try out a simple rack middleware "hello world", but i seem to get stuck. it looks like the main sytax changed, since some examples use this code:
require 'rack/utils'
class FooBar
def initialize(app)
@app = app
end
def call(env)
status, headers, body = @app.call(env)
body.body << "\nHi from #{self.class}"
[status, headers, body]
end
end
produces an error:
undefined method `<<' for #<ActionDispatch::Response:0x103f07c48>
even when i look at other codes out there, i cannot seem to get them running with rails 3.0.3.
here are my concrete questions:
- how can i get a simple rack middleware to run and modify the body of any output from a rails app?
- where should i put the Rails.application.config.middleware.use declaration? (i created an own initializer in config/initializers for that)
thanks a lot in advance!