Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2017-10-26 17:06:51 +0300
committerBob Van Landuyt <bob@vanlanduyt.co>2017-11-07 21:52:09 +0300
commit414c4e3fd83a6a3cae623dcc8135d6ef09a30562 (patch)
treed084e53e0cc2bcfe994987511a8759068d002db2 /lib/gitlab/routing.rb
parent3a8cf27674341e345bcbb823506f350849178ed7 (diff)
Add helper methods to redirect legacy paths
Diffstat (limited to 'lib/gitlab/routing.rb')
-rw-r--r--lib/gitlab/routing.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/gitlab/routing.rb b/lib/gitlab/routing.rb
index e57890f1143..abfd413b7ea 100644
--- a/lib/gitlab/routing.rb
+++ b/lib/gitlab/routing.rb
@@ -40,5 +40,14 @@ module Gitlab
def self.url_helpers
@url_helpers ||= Gitlab::Application.routes.url_helpers
end
+
+ def self.redirect_legacy_paths(router, *paths)
+ paths.each do |path|
+ router.match "/#{path}(/*rest)",
+ via: [:get, :post, :patch, :delete],
+ to: router.redirect { |_params, request| request.fullpath.gsub(%r{/#{path}/*}, "/-/#{path}/") },
+ as: "legacy_#{path}_redirect"
+ end
+ end
end
end