routes.rb 4.1 KB
Newer Older
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
1
require 'sidekiq/web'
2
require 'sidekiq/cron/web'
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
3

Valeriy's avatar
Valeriy committed
4
Rails.application.routes.draw do
5 6
  concern :access_requestable do
    post :request_access, on: :collection
7
    post :approve_access_request, on: :member
8 9
  end

10 11 12 13
  concern :awardable do
    post :toggle_award_emoji, on: :member
  end

14 15 16 17 18 19
  favicon_redirect = redirect do |_params, _request|
    ActionController::Base.helpers.asset_url(Gitlab::Favicon.main)
  end
  get 'favicon.png', to: favicon_redirect
  get 'favicon.ico', to: favicon_redirect

20 21 22
  draw :sherlock
  draw :development
  draw :ci
23

Valeriy's avatar
Valeriy committed
24
  use_doorkeeper do
25 26 27
    controllers applications: 'oauth/applications',
                authorized_applications: 'oauth/authorized_applications',
                authorizations: 'oauth/authorizations'
Valeriy's avatar
Valeriy committed
28
  end
29

30 31 32 33
  # This is here so we can "reserve" the path for the Jira integration in GitLab EE
  # Having a non-existent controller here does not affect the scope in any way since all possible routes
  # get a 404 proc returned. It is written in this way to minimize merge conflicts with EE
  scope path: '/login/oauth', controller: 'oauth/jira/authorizations', as: :oauth_jira do
34
    match '*all', via: [:get, :post], to: proc { [404, {}, ['']] }
35 36
  end

37 38
  draw :oauth

39 40
  use_doorkeeper_openid_connect

41 42 43
  # Autocomplete
  get '/autocomplete/users' => 'autocomplete#users'
  get '/autocomplete/users/:id' => 'autocomplete#user'
44
  get '/autocomplete/projects' => 'autocomplete#projects'
45
  get '/autocomplete/award_emojis' => 'autocomplete#award_emojis'
46
  get '/autocomplete/merge_request_target_branches' => 'autocomplete#merge_request_target_branches'
47

48
  # Search
49 50
  get 'search' => 'search#show'
  get 'search/autocomplete' => 'search#autocomplete', as: :search_autocomplete
Valeriy's avatar
Valeriy committed
51

Kamil Trzciński's avatar
Kamil Trzciński committed
52 53 54
  # JSON Web Token
  get 'jwt/auth' => 'jwt#auth'

55
  # Health check
56
  get 'health_check(/:checks)' => 'health_check#index', as: :health_check
57

58
  scope path: '-' do
59
    # '/-/health' implemented by BasicHealthMiddleware
60 61
    get 'liveness' => 'health#liveness'
    get 'readiness' => 'health#readiness'
62
    resources :metrics, only: [:index]
63
    mount Peek::Railtie => '/peek', as: 'peek_routes'
64 65 66 67 68 69 70 71 72 73 74 75 76

    # Boards resources shared between group and projects
    resources :boards, only: [] do
      resources :lists, module: :boards, only: [:index, :create, :update, :destroy] do
        collection do
          post :generate
        end

        resources :issues, only: [:index, :create, :update]
      end

      resources :issues, module: :boards, only: [:index, :update]
    end
77

78 79 80 81 82 83 84 85
    # UserCallouts
    resources :user_callouts, only: [:create]

    get 'ide' => 'ide#index'
    get 'ide/*vueroute' => 'ide#index', format: false

    draw :operations
    draw :instance_statistics
86

87 88 89 90 91 92
    if ENV['GITLAB_ENABLE_CHAOS_ENDPOINTS']
      get '/chaos/leakmem' => 'chaos#leakmem'
      get '/chaos/cpuspin' => 'chaos#cpuspin'
      get '/chaos/sleep' => 'chaos#sleep'
      get '/chaos/kill' => 'chaos#kill'
    end
93 94 95 96
  end

  concern :clusterable do
    resources :clusters, only: [:index, :new, :show, :update, :destroy] do
97 98 99 100 101 102 103 104
      collection do
        post :create_user
        post :create_gcp
      end

      member do
        scope :applications do
          post '/:application', to: 'clusters/applications#create', as: :install_applications
105
          patch '/:application', to: 'clusters/applications#update', as: :update_applications
106 107
        end

108
        get :cluster_status, format: :json
109 110
      end
    end
111 112
  end

113 114 115 116
  draw :api
  draw :sidekiq
  draw :help
  draw :snippets
117

Douwe Maan's avatar
Douwe Maan committed
118 119 120 121
  # Invites
  resources :invites, only: [:show], constraints: { id: /[A-Za-z0-9_-]+/ } do
    member do
      post :accept
Douwe Maan's avatar
Douwe Maan committed
122
      match :decline, via: [:get, :post]
Douwe Maan's avatar
Douwe Maan committed
123 124
    end
  end
125

126
  resources :sent_notifications, only: [], constraints: { id: /\h{32}/ } do
127 128 129 130 131
    member do
      get :unsubscribe
    end
  end

132 133 134
  # Spam reports
  resources :abuse_reports, only: [:new, :create]

135 136 137
  # Notification settings
  resources :notification_settings, only: [:create, :update]

138
  draw :google_api
139 140 141 142 143 144 145 146 147
  draw :import
  draw :uploads
  draw :explore
  draw :admin
  draw :profile
  draw :dashboard
  draw :group
  draw :user
  draw :project
gitlabhq's avatar
gitlabhq committed
148

149
  root to: "root#index"
150

151
  get '*unmatched_route', to: 'application#route_not_found'
gitlabhq's avatar
gitlabhq committed
152
end