Skip to content

Instantly share code, notes, and snippets.

@nateberkopec
Created March 28, 2013 19:44
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save nateberkopec/5266206 to your computer and use it in GitHub Desktop.
Example of a simple Rack middleware for scrubbing your Rack headers of sensitive information.
class Rack::SecureHeaders
def initialize(app, options = {})
@app, @options = app, options
end
def call(env)
response = @app.call(env)
# [status, headers, response] = response
# Uncomment any of the following that make sense for your application:
# response[1].delete "X-Runtime"
# response[1].delete "Server"
# response[1].delete "X-Rack-Cache"
response
end
end
# MyApp::Application.configure do
# config.middleware.insert_after(Rack::Lock, Rack::SecureHeaders)
# end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment