Example of a simple Rack middleware for scrubbing your Rack headers of sensitive information.
This file contains 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
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