Rack::ResponseHeaders in rackup for Sinatra

Posted by sevennineteen on Stack Overflow See other posts from Stack Overflow or by sevennineteen
Published on 2010-05-25T12:21:43Z Indexed on 2010/05/26 23:21 UTC
Read the original article Hit count: 268

Filed under:
|
|

I think this is a very easy one, but I can't seem to get it right. Basically, I'm trying to use Rack middleware to set a default Cache-Control header into all responses served by my Sinatra app. It looks like Rack::ResponseHeaders should be able to do exactly what I need, but I get an error when attempting to use the syntax demonstrated here in my rackup file:

use Rack::ResponseHeaders do |headers|
    headers['X-Foo'] = 'bar'
    headers.delete('X-Baz')
end

I was able to get Rack::Cache to work successfully as follows:

use Rack::Cache,
    :default_ttl => 3600

However, this doesn't achieve exactly the output I want, whereas Rack::ResponseHeaders gives fine-grained control of the headers.

FYI, my site is hosted on Heroku, and the required Rack gems are specified in my .gems manifest.

Thanks!

Update: After doing some research, it looks like the first issue is that Rack::ResponseHeaders is not found in the version of rack-contrib (0.9.2) which was installed. I'll start by looking into that.

© Stack Overflow or respective owner

Related posts about sinatra

Related posts about heroku