diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-05-02 17:05:20 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-05-03 09:59:21 -0700 |
commit | af8c54be0a88af7e8227f156257236a10da7ffbe (patch) | |
tree | 092c2ee12aa9121cc799a6b18dec33131b3db165 | |
parent | dd7afdb2dc95a934df50c72b36ba6c80b5ac4944 (diff) | |
download | rails-af8c54be0a88af7e8227f156257236a10da7ffbe.tar.gz rails-af8c54be0a88af7e8227f156257236a10da7ffbe.tar.bz2 rails-af8c54be0a88af7e8227f156257236a10da7ffbe.zip |
cache strings in the AST for faster comparison than include?
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/static.rb | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/static.rb b/actionpack/lib/action_dispatch/middleware/static.rb index 360c1209bb..404943d720 100644 --- a/actionpack/lib/action_dispatch/middleware/static.rb +++ b/actionpack/lib/action_dispatch/middleware/static.rb @@ -35,18 +35,15 @@ module ActionDispatch end class Static - FILE_METHODS = %w(GET HEAD).freeze - def initialize(app, path, cache_control=nil) @app = app @file_handler = FileHandler.new(path, cache_control) end def call(env) - path = env['PATH_INFO'].chomp('/') - method = env['REQUEST_METHOD'] - - if FILE_METHODS.include?(method) + 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) |