Created
December 17, 2012 19:00
-
-
Save anveo/4320919 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Rack | |
class ServerNameHeader | |
attr_reader :app, :hostname | |
def initialize(app) | |
@app = app | |
@hostname = `hostname`.strip | |
end | |
def call(env) | |
status, headers, body = *app.call(env) | |
headers['X-Server-Name'] = hostname | |
[status, headers, body] | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/environments/production.rb | |
require File.expand_path('../../../lib/rack/server_name_header', __FILE__) | |
My::Application.configure do | |
config.middleware.use Rack::ServerNameHeader | |
# all the other stuff | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment