Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# In /lib/foo_bar_middleware.rb
class FooBarMiddleware
def initialize(app, options={})
@app = app
# options will be {:foo => :bar} if you look lower down, you can use this in other methods etc
@options = options
end
def call(env)
request = ::Rack::Request.new(env)
@cookies = request.cookies
@app.call(env)
end
end
# In environment.rb:
config.middleware.insert_before(ActionController::Session::CookieStore, 'FooBarMiddleware', {:foo => :bar})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment