Skip to content

Commit

Permalink
Added middleware for checking defined things.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Pankowecki (Gavdi) committed Jul 16, 2011
1 parent 113bef2 commit c70d0bd
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion test/dummy309/config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
class DefinedMiddleware
def initialize(app)
@app = app
end
def call(env)
path = env['PATH_INFO']
if m = path.match(/^\/const\/(.*)/)
const = m[1]
answer = eval("defined?(#{const})")
return [200, {}, answer.to_s]
else
@app.call(env)
end
end
end

Dummy309::Application.configure do
# Settings specified here will take precedence over those in config/application.rb

Expand All @@ -22,5 +38,6 @@

# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin
end

config.middleware.insert_after(ActionDispatch::Static, DefinedMiddleware)
end

0 comments on commit c70d0bd

Please sign in to comment.