Commit 7ef0f01a authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Draw EE routes before CE routes

This makes it so that more specific routes are defined first. This
improves routing as the router matches the correct route faster.

Extracted from:
https://gitlab.com/gitlab-org/gitlab/merge_requests/19412
parent 21319e7a
...@@ -268,12 +268,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -268,12 +268,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
post :validate_query, on: :collection post :validate_query, on: :collection
end end
end end
Gitlab.ee do
resources :alerts, constraints: { id: /\d+/ }, only: [:index, :create, :show, :update, :destroy] do
post :notify, on: :collection
end
end
end end
resources :merge_requests, concerns: :awardable, except: [:new, :create, :show], constraints: { id: /\d+/ } do resources :merge_requests, concerns: :awardable, except: [:new, :create, :show], constraints: { id: /\d+/ } do
...@@ -376,17 +370,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -376,17 +370,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end end
end end
Gitlab.ee do
resources :path_locks, only: [:index, :destroy] do
collection do
post :toggle
end
end
get '/service_desk' => 'service_desk#show', as: :service_desk
put '/service_desk' => 'service_desk#update', as: :service_desk_refresh
end
Gitlab.ee do Gitlab.ee do
resources :push_rules, constraints: { id: /\d+/ }, only: [:update] resources :push_rules, constraints: { id: /\d+/ }, only: [:update]
end end
...@@ -409,11 +392,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -409,11 +392,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
get :failures get :failures
get :status get :status
get :test_report get :test_report
Gitlab.ee do
get :security
get :licenses
end
end end
member do member do
...@@ -538,24 +516,11 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -538,24 +516,11 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
get :realtime_changes get :realtime_changes
post :create_merge_request post :create_merge_request
get :discussions, format: :json get :discussions, format: :json
Gitlab.ee do
get 'designs(/*vueroute)', to: 'issues#designs', as: :designs, format: false
end
end end
collection do collection do
post :bulk_update post :bulk_update
post :import_csv post :import_csv
Gitlab.ee do
post :export_csv
get :service_desk
end
end
Gitlab.ee do
resources :issue_links, only: [:index, :create, :destroy], as: 'links', path: 'links'
end end
end end
...@@ -637,6 +602,16 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -637,6 +602,16 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
Gitlab.ee do Gitlab.ee do
resources :managed_licenses, only: [:index, :show, :new, :create, :edit, :update, :destroy] resources :managed_licenses, only: [:index, :show, :new, :create, :edit, :update, :destroy]
end end
# Legacy routes.
# Introduced in 12.0.
# Should be removed with https://gitlab.com/gitlab-org/gitlab/issues/28848.
Gitlab::Routing.redirect_legacy_paths(self, :settings, :branches, :tags,
:network, :graphs, :autocomplete_sources,
:project_members, :deploy_keys, :deploy_tokens,
:labels, :milestones, :services, :boards, :releases,
:forks, :group_links, :import, :avatar, :mirror,
:cycle_analytics, :mattermost, :variables, :triggers)
end end
resources(:projects, resources(:projects,
...@@ -661,23 +636,4 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -661,23 +636,4 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end end
end end
end end
# Legacy routes.
# Introduced in 12.0.
# Should be removed with https://gitlab.com/gitlab-org/gitlab/issues/28848.
scope(path: '*namespace_id',
as: :namespace,
namespace_id: Gitlab::PathRegex.full_namespace_route_regex) do
scope(path: ':project_id',
constraints: { project_id: Gitlab::PathRegex.project_route_regex },
module: :projects,
as: :project) do
Gitlab::Routing.redirect_legacy_paths(self, :settings, :branches, :tags,
:network, :graphs, :autocomplete_sources,
:project_members, :deploy_keys, :deploy_tokens,
:labels, :milestones, :services, :boards, :releases,
:forks, :group_links, :import, :avatar, :mirror,
:cycle_analytics, :mattermost, :variables, :triggers)
end
end
end end
# frozen_string_literal: true # frozen_string_literal: true
namespace :admin do namespace :admin do
resources :users, constraints: { id: %r{[a-zA-Z./0-9_\-]+} } do resources :users, only: [], constraints: { id: %r{[a-zA-Z./0-9_\-]+} } do
member do member do
post :reset_runners_minutes post :reset_runners_minutes
end end
......
...@@ -145,14 +145,6 @@ constraints(::Constraints::GroupUrlConstrainer.new) do ...@@ -145,14 +145,6 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
resource :roadmap, only: [:show], controller: 'roadmap' resource :roadmap, only: [:show], controller: 'roadmap'
legacy_ee_group_boards_redirect = redirect do |params, request|
path = "/groups/#{params[:group_id]}/-/boards"
path << "/#{params[:extra_params]}" if params[:extra_params].present?
path << "?#{request.query_string}" if request.query_string.present?
path
end
get 'boards(/*extra_params)', as: :legacy_ee_group_boards_redirect, to: legacy_ee_group_boards_redirect
resource :dependency_proxy, only: [:show, :update] resource :dependency_proxy, only: [:show, :update]
resources :packages, only: [:index] resources :packages, only: [:index]
end end
......
...@@ -54,6 +54,18 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -54,6 +54,18 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end end
# End of the /-/ scope. # End of the /-/ scope.
resources :path_locks, only: [:index, :destroy] do
collection do
post :toggle
end
end
namespace :prometheus do
resources :alerts, constraints: { id: /\d+/ }, only: [:index, :create, :show, :update, :destroy] do
post :notify, on: :collection
end
end
post 'alerts/notify', to: 'alerting/notifications#create' post 'alerts/notify', to: 'alerting/notifications#create'
resource :tracing, only: [:show] resource :tracing, only: [:show]
...@@ -72,9 +84,20 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -72,9 +84,20 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resources :issues, only: [], constraints: { id: /\d+/ } do resources :issues, only: [], constraints: { id: /\d+/ } do
member do member do
get '/descriptions/:version_id/diff', action: :description_diff, as: :description_diff get '/descriptions/:version_id/diff', action: :description_diff, as: :description_diff
get '/designs(/*vueroute)', to: 'issues#designs', as: :designs, format: false
end end
collection do
post :export_csv
get :service_desk
end
resources :issue_links, only: [:index, :create, :destroy], as: 'links', path: 'links'
end end
get '/service_desk' => 'service_desk#show', as: :service_desk
put '/service_desk' => 'service_desk#update', as: :service_desk_refresh
resources :merge_requests, only: [], constraints: { id: /\d+/ } do resources :merge_requests, only: [], constraints: { id: /\d+/ } do
member do member do
get '/descriptions/:version_id/diff', action: :description_diff, as: :description_diff get '/descriptions/:version_id/diff', action: :description_diff, as: :description_diff
...@@ -87,15 +110,19 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -87,15 +110,19 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end end
end end
resources :pipelines, only: [] do
member do
get :security
get :licenses
end
end
resource :insights, only: [:show], trailing_slash: true do resource :insights, only: [:show], trailing_slash: true do
collection do collection do
post :query post :query
end end
end end
resource :dependencies, only: [:show]
resource :licenses, only: [:show]
namespace :security do namespace :security do
resources :dependencies, only: [:index] resources :dependencies, only: [:index]
resources :licenses, only: [:index] resources :licenses, only: [:index]
...@@ -115,6 +142,9 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -115,6 +142,9 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end end
end end
end end
resource :dependencies, only: [:show]
resource :licenses, only: [:show]
end end
end end
end end
......
...@@ -10,7 +10,7 @@ module Gitlab ...@@ -10,7 +10,7 @@ module Gitlab
RoutesNotFound = Class.new(StandardError) RoutesNotFound = Class.new(StandardError)
def draw(routes_name) def draw(routes_name)
drawn_any = draw_ce(routes_name) | draw_ee(routes_name) drawn_any = draw_ee(routes_name) | draw_ce(routes_name)
drawn_any || raise(RoutesNotFound.new("Cannot find #{routes_name}")) drawn_any || raise(RoutesNotFound.new("Cannot find #{routes_name}"))
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment