Skip to content

Instantly share code, notes, and snippets.

@cheeyeo
Forked from ismasan/config.ru
Created January 27, 2016 21:43
Show Gist options
  • Save cheeyeo/8de99c7bb76b84eff2b5 to your computer and use it in GitHub Desktop.
Save cheeyeo/8de99c7bb76b84eff2b5 to your computer and use it in GitHub Desktop.
Custom top level rack middleware
# 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