summaryrefslogtreecommitdiff
path: root/config/routes.rb
diff options
context:
space:
mode:
Diffstat (limited to 'config/routes.rb')
-rw-r--r--config/routes.rb27
1 files changed, 26 insertions, 1 deletions
diff --git a/config/routes.rb b/config/routes.rb
index 31e483df326..90a26c0a20f 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'sidekiq/web'
require 'sidekiq/cron/web'
require 'product_analytics/collector_app'
@@ -60,9 +62,10 @@ Rails.application.routes.draw do
end
# Search
- get 'search' => 'search#show'
+ get 'search' => 'search#show', as: :search
get 'search/autocomplete' => 'search#autocomplete', as: :search_autocomplete
get 'search/count' => 'search#count', as: :search_count
+ get 'search/opensearch' => 'search#opensearch', as: :search_opensearch
# JSON Web Token
get 'jwt/auth' => 'jwt#auth'
@@ -158,6 +161,7 @@ Rails.application.routes.draw do
get :db_spin
get :sleep
get :kill
+ post :gc
end
end
@@ -288,7 +292,28 @@ Rails.application.routes.draw do
get '/sitemap' => 'sitemap#show', format: :xml
end
+ # Creates shorthand helper methods for project resources.
+ # For example; for the `namespace_project_path` this also creates `project_path`.
+ #
+ # TODO: We don't need the `Gitlab::Routing` module at all as we can use
+ # the `direct` DSL method of Rails to define url helpers. Move all the
+ # custom url helpers to use the `direct` DSL method and remove the `Gitlab::Routing`.
+ # For more information: https://gitlab.com/gitlab-org/gitlab/-/issues/299583
+ Gitlab::Application.routes.set.filter_map { |route| route.name if route.name&.include?('namespace_project') }.each do |name|
+ new_name = name.sub('namespace_project', 'project')
+
+ direct(new_name) do |project, *args|
+ # This is due to a bug I've found in Rails.
+ # For more information: https://gitlab.com/gitlab-org/gitlab/-/issues/299591
+ args.pop if args.last == {}
+
+ send("#{name}_url", project&.namespace, project, *args)
+ end
+ end
+
root to: "root#index"
get '*unmatched_route', to: 'application#route_not_found'
end
+
+Gitlab::Routing.add_helpers(TimeboxesRoutingHelper)