Skip to content

Instantly share code, notes, and snippets.

@richmolj
Created June 21, 2013 15:44
Show Gist options
  • Save richmolj/5832106 to your computer and use it in GitHub Desktop.
Save richmolj/5832106 to your computer and use it in GitHub Desktop.
# not real code
module Rack
class Director
def call(env)
@request = Rack::Request.new(env)
status, headers, body = @app.call(env)
@response = Rack::Response.new(body, status, headers)
if authenticated?
# inject toolbar
end
@response.finish
end
def authenticated?
config.authencation_proc.call(@request) == true
end
end
end
# in initializer
Rack::Director.configure do |c|
c.authentication_proc = proc { |request| request.env['warden'].user.authenticated? }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment