From c59734f756b79c39486c45273d2cc5d42cd0c864 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Thu, 6 Dec 2012 17:06:59 +0000 Subject: Invert precedence of content in ActionDispatch::Static This commit inverts the precedence in ActionDispatch::Static so that dynamic content will be served before static content. This is so that precompiled assets do not inadvertently get included when running in development mode - it should have no effect in production where static files are usually handled by the web server. Closes #6421 --- actionpack/lib/action_dispatch/middleware/static.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'actionpack/lib/action_dispatch') diff --git a/actionpack/lib/action_dispatch/middleware/static.rb b/actionpack/lib/action_dispatch/middleware/static.rb index e3b15b43b9..65670b0ff1 100644 --- a/actionpack/lib/action_dispatch/middleware/static.rb +++ b/actionpack/lib/action_dispatch/middleware/static.rb @@ -51,16 +51,20 @@ module ActionDispatch end def call(env) - case env['REQUEST_METHOD'] - when 'GET', 'HEAD' - path = env['PATH_INFO'].chomp('/') - if match = @file_handler.match?(path) - env["PATH_INFO"] = match - return @file_handler.call(env) + path = env['PATH_INFO'].chomp('/') + response = @app.call(env) + + if response[1]['X-Cascade'] == 'pass' + case env['REQUEST_METHOD'] + when 'GET', 'HEAD' + if match = @file_handler.match?(path) + env["PATH_INFO"] = match + return @file_handler.call(env) + end end end - @app.call(env) + response end end end -- cgit v1.2.3