-
-
Save cheeyeo/8de99c7bb76b84eff2b5 to your computer and use it in GitHub Desktop.
Custom top level rack middleware
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
# This file is used by Rack-based servers to start the application. | |
require ::File.expand_path('../config/environment', __FILE__) | |
class MyMiddleware | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
path = env['PATH_INFO'] | |
env['PATH_INFO'] = '/hello/peter' | |
req = @app.call env | |
req[1]['Custom-Header'] = ' Hello Peter' | |
req | |
end | |
end | |
run MyMiddleware.new(Rails.application) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment