Wow! Awesome answer, you rock! Enviado desde el movil
El 12/05/2013, a las 21:20, Eric Wong <[email protected]> escribió: > pille <[email protected]> wrote: >> hi, >> >> is it possible to add static and dynamic HTTP response headers in >> unicorn.conf.rb? > > No, but it is easily possible with a Rack config.ru > >> i'd like to add the hostname of the worker for debugging and a >> timestamp, when the request was worked on. >> >> currently this is done in nginx, which should be stripped from the stack. >> i'd like to keep it out of the webapp itself, because it's infrastructure. > > Can you consider config.ru infrastructure? unicorn tries to do as > much generically via Rack as possible. > > The following (totally untested) middleware should work: > ------------------------8<------------------------ > require 'time' > require 'socket' > require 'rack/utils' > > # Usage (in config.ru) > # require 'name/of/this/file' > # use ExtraHeaders > # # other middlewares ... > # run YourApp.new > class ExtraHeaders > def initialize(app) > @app = app > end > > def call(env) > start = Time.now.httpdate > status, headers, body = @app.call(env) > headers = Rack::Utils::HeaderHash.new(headers) > headers["X-Hostname"] = Socket.gethostname > headers["X-Start"] = start > [ status, headers, body ] > end > end > ------------------------8<------------------------ > _______________________________________________ > Unicorn mailing list - [email protected] > http://rubyforge.org/mailman/listinfo/mongrel-unicorn > Do not quote signatures (like this one) or top post when replying _______________________________________________ Unicorn mailing list - [email protected] http://rubyforge.org/mailman/listinfo/mongrel-unicorn Do not quote signatures (like this one) or top post when replying
