Skip to content

Instantly share code, notes, and snippets.

@ismasan
Created January 6, 2016 11:37
Show Gist options
  • Save ismasan/a6b1f9a73e43f8395824 to your computer and use it in GitHub Desktop.
Save ismasan/a6b1f9a73e43f8395824 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