Skip to content

Instantly share code, notes, and snippets.

@masqita
Created July 9, 2010 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masqita/469445 to your computer and use it in GitHub Desktop.
Save masqita/469445 to your computer and use it in GitHub Desktop.
# 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