diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-02-20 12:44:07 +0100 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-02-20 12:44:07 +0100 |
commit | 4310431ee73fdd6aa3874aaccc0a901252e7f61f (patch) | |
tree | 97065a9c0862ccd467b3f8e6789922731b68804f | |
parent | eb210f4a1876f0dbf70b8c3ae855b6a986777421 (diff) | |
download | gitlab-ce-4310431ee73fdd6aa3874aaccc0a901252e7f61f.tar.gz |
Use modified ActionDispatch::Static to let uploads go through to routes.
-rw-r--r-- | config/initializers/static_files.rb | 13 | ||||
-rw-r--r-- | lib/gitlab/middleware/static.rb | 13 |
2 files changed, 26 insertions, 0 deletions
diff --git a/config/initializers/static_files.rb b/config/initializers/static_files.rb new file mode 100644 index 00000000000..e04c29cee4a --- /dev/null +++ b/config/initializers/static_files.rb @@ -0,0 +1,13 @@ +begin + app = Rails.application + + app.config.middleware.swap( + ActionDispatch::Static, + Gitlab::Middleware::Static, + app.paths["public"].first, + app.config.static_cache_control + ) +rescue + # If ActionDispatch::Static wasn't loaded onto the stack (like in production), + # an exception is raised. +end
\ No newline at end of file diff --git a/lib/gitlab/middleware/static.rb b/lib/gitlab/middleware/static.rb new file mode 100644 index 00000000000..b92319c95d4 --- /dev/null +++ b/lib/gitlab/middleware/static.rb @@ -0,0 +1,13 @@ +module Gitlab + module Middleware + class Static < ActionDispatch::Static + UPLOADS_REGEX = /\A\/uploads(\/|\z)/.freeze + + def call(env) + return @app.call(env) if env['PATH_INFO'] =~ UPLOADS_REGEX + + super + end + end + end +end
\ No newline at end of file |