Read about our upcoming Code of Conduct on this issue

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

gitlabhq's avatar
gitlabhq committed
4
Gitlab::Application.routes.draw do
Valery Sizov's avatar
Valery Sizov committed
5
6
7
8
9
  use_doorkeeper do
    controllers :applications => 'oauth/applications',
                :authorized_applications => 'oauth/authorized_applications',
                :authorizations => 'oauth/authorizations'
  end
10
11
12
  #
  # Search
  #
13
14
  get 'search' => 'search#show'
  get 'search/autocomplete' => 'search#autocomplete', as: :search_autocomplete
Valery Sizov's avatar
Valery Sizov committed
15

16
  # API
17
18
  API::API.logger Rails.logger
  mount API::API => '/api'
19

GitLab's avatar
GitLab committed
20
  # Get all keys of user
21
22
  get ':username.keys' => 'profiles/keys#get_keys' , constraints: { username: /.*/ }

23
  constraint = lambda { |request| request.env['warden'].authenticate? and request.env['warden'].user.admin? }
Dmitriy Zaporozhets's avatar
sidekiq    
Dmitriy Zaporozhets committed
24
  constraints constraint do
25
    mount Sidekiq::Web, at: '/admin/sidekiq', as: :sidekiq
Dmitriy Zaporozhets's avatar
sidekiq    
Dmitriy Zaporozhets committed
26
  end
Ariejan de Vroom's avatar
Ariejan de Vroom committed
27

28
29
  # Enable Grack support
  mount Grack::Bundle.new({
30
    git_path:     Gitlab.config.git.bin_path,
31
32
33
    project_root: Gitlab.config.gitlab_shell.repos_path,
    upload_pack:  Gitlab.config.gitlab_shell.upload_pack,
    receive_pack: Gitlab.config.gitlab_shell.receive_pack
34
  }), at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) }, via: [:get, :post]
35

36
37
38
  #
  # Help
  #
Job van der Voort's avatar
Job van der Voort committed
39
40

  get 'help'                  => 'help#index'
41
  get 'help/:category/:file'  => 'help#show', as: :help_page
Marin Jankovski's avatar
Marin Jankovski committed
42
  get 'help/shortcuts'
43

Andrew8xx8's avatar
Andrew8xx8 committed
44
45
46
47
48
  #
  # Global snippets
  #
  resources :snippets do
    member do
49
      get 'raw'
Andrew8xx8's avatar
Andrew8xx8 committed
50
51
    end
  end
52
  get '/s/:username' => 'snippets#user_index', as: :user_snippets, constraints: { username: /.*/ }
Andrew8xx8's avatar
Andrew8xx8 committed
53

Valery Sizov's avatar
Valery Sizov committed
54
55
56
57
58
59
  #
  # Github importer area
  #
  resource :github_import, only: [:create, :new] do
    get :status
    get :callback
60
    get :jobs
Valery Sizov's avatar
Valery Sizov committed
61
62
  end

63
  #
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
64
  # Explroe area
65
  #
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
66
67
68
69
  namespace :explore do
    resources :projects, only: [:index] do
      collection do
        get :trending
70
        get :starred
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
71
72
73
      end
    end

74
    resources :groups, only: [:index]
75
    root to: 'projects#trending'
76
77
  end

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
78
  # Compatibility with old routing
79
80
  get 'public' => 'explore/projects#index'
  get 'public/projects' => 'explore/projects#index'
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
81

82
83
84
  #
  # Attachments serving
  #
85
  get 'files/:type/:id/:filename' => 'files#download', constraints: { id: /\d+/, type: /[a-z]+/, filename:  /.+/ }
86

87
88
89
  #
  # Admin Area
  #
Nihad Abbasov's avatar
Nihad Abbasov committed
90
  namespace :admin do
91
    resources :users, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do
92
      resources :keys, only: [:show, :destroy]
93
      member do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
94
        put :team_update
95
96
        put :block
        put :unblock
97
        delete 'remove/:email_id', action: 'remove_email', as: 'remove_email'
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
98
99
      end
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
100

Valery Sizov's avatar
Valery Sizov committed
101
102
    resources :applications

103
104
    resources :groups, constraints: { id: /[^\/]+/ } do
      member do
105
        put :project_teams_update
106
      end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
107
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
108

Robert Speicher's avatar
Robert Speicher committed
109
    resources :hooks, only: [:index, :create, :destroy] do
Valeriy Sizov's avatar
Valeriy Sizov committed
110
111
      get :test
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
112

113
    resources :broadcast_messages, only: [:index, :create, :destroy]
114
    resource :logs, only: [:show]
115
    resource :background_jobs, controller: 'background_jobs', only: [:show]
116
117
118
119
120
121
122

    resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:index, :show] do
      member do
        put :transfer
      end
    end

123
    resource :application_settings, only: [:show, :update]
124

125
    root to: 'dashboard#index'
gitlabhq's avatar
gitlabhq committed
126
127
  end

randx's avatar
randx committed
128
129
130
  #
  # Profile Area
  #
131
132
133
134
  resource :profile, only: [:show, :update] do
    member do
      get :history
      get :design
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
135
      get :applications
136
137
138
139

      put :reset_private_token
      put :update_username
    end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
140

141
    scope module: :profiles do
142
      resource :account, only: [:show, :update]
143
      resource :notifications, only: [:show, :update]
144
145
146
147
148
      resource :password, only: [:new, :create, :edit, :update] do
        member do
          put :reset
        end
      end
149
      resources :keys
150
      resources :emails, only: [:index, :create, :destroy]
151
152
153
154
155
      resources :groups, only: [:index] do
        member do
          delete :leave
        end
      end
156
      resource :avatar, only: [:destroy]
157
    end
158
  end
Robert Speicher's avatar
Robert Speicher committed
159

160
161
  get '/u/:username' => 'users#show', as: :user,
      constraints: { username: /(?:[^.]|\.(?!atom$))+/, format: /atom/ }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
162

randx's avatar
randx committed
163
164
165
  #
  # Dashboard Area
  #
166
  resource :dashboard, controller: 'dashboard', only: [:show] do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
167
168
169
170
171
172
    member do
      get :projects
      get :issues
      get :merge_requests
    end
  end
gitlabhq's avatar
gitlabhq committed
173

randx's avatar
randx committed
174
175
176
  #
  # Groups Area
  #
177
  resources :groups, constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/}  do
randx's avatar
randx committed
178
179
180
    member do
      get :issues
      get :merge_requests
181
      get :members
182
      get :projects
randx's avatar
randx committed
183
    end
184

Steven Thonus's avatar
Steven Thonus committed
185
    scope module: :groups do
186
      resources :group_members, only: [:create, :update, :destroy]
Steven Thonus's avatar
Steven Thonus committed
187
      resource :avatar, only: [:destroy]
188
      resources :milestones
Steven Thonus's avatar
Steven Thonus committed
189
    end
randx's avatar
randx committed
190
191
  end

Robert Speicher's avatar
Robert Speicher committed
192
  resources :projects, constraints: { id: /[^\/]+/ }, only: [:new, :create]
193

194
  devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations , passwords: :passwords, sessions: :sessions, confirmations: :confirmations }
gitlabhq's avatar
gitlabhq committed
195

196
  devise_scope :user do
197
    get '/users/auth/:provider/omniauth_error' => 'omniauth_callbacks#omniauth_error', as: :omniauth_error
198
  end
199
200
201
  #
  # Project Area
  #
202
  resources :projects, constraints: { id: /[a-zA-Z.0-9_\-]+\/[a-zA-Z.0-9_\-]+/ }, except: [:new, :create, :index], path: '/' do
203
204
    member do
      put :transfer
205
206
      post :archive
      post :unarchive
207
      post :upload_image
Ciro Santilli's avatar
Ciro Santilli committed
208
      post :toggle_star
209
      get :markdown_preview
210
      get :autocomplete_sources
211
212
    end

213
    scope module: :projects do
214
      resources :blob, only: [:show, :destroy], constraints: { id: /.+/, format: false } do
skv's avatar
skv committed
215
216
        get :diff, on: :member
      end
217
218
      resources :raw,       only: [:show], constraints: {id: /.+/}
      resources :tree,      only: [:show], constraints: {id: /.+/, format: /(html|js)/ }
skv-headless's avatar
skv-headless committed
219
      resources :edit_tree, only: [:show, :update], constraints: { id: /.+/ }, path: 'edit' do
Ciro Santilli's avatar
Ciro Santilli committed
220
        # Cannot be GET to differentiate from GET paths that end in preview.
skv-headless's avatar
skv-headless committed
221
222
        post :preview, on: :member
      end
223
      resource  :avatar,    only: [:show, :destroy]
224
225
226
227
228
      resources :new_tree,  only: [:show, :update], constraints: {id: /.+/}, path: 'new'
      resources :commit,    only: [:show], constraints: {id: /[[:alnum:]]{6,40}/}
      resources :commits,   only: [:show], constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/}
      resources :compare,   only: [:index, :create]
      resources :blame,     only: [:show], constraints: {id: /.+/}
229
      resources :network,   only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}
230
231
232
233
234
      resources :graphs,    only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/} do
        member do
          get :commits
        end
      end
235

236
237
      get '/compare/:from...:to' => 'compare#show', :as => 'compare',
          :constraints => {from: /.+/, to: /.+/}
238

239
240
      resources :snippets, constraints: {id: /\d+/} do
        member do
241
          get 'raw'
242
        end
243
      end
244

Marin Jankovski's avatar
Marin Jankovski committed
245
      resources :wikis, only: [:show, :edit, :destroy, :create], constraints: {id: /[a-zA-Z.0-9_\-\/]+/} do
246
247
248
249
250
        collection do
          get :pages
          put ':id' => 'wikis#update'
          get :git_access
        end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
251

252
        member do
253
          get 'history'
254
        end
Valery Sizov's avatar
Valery Sizov committed
255
      end
Valery Sizov's avatar
Valery Sizov committed
256

257
      resource :fork, only: [:new, :create]
258
      resource :import, only: [:new, :create, :show]
259

260
      resource :repository, only: [:show, :create] do
261
        member do
262
          get 'archive', constraints: { format: Gitlab::Regex.archive_formats_regex }
263
        end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
264
      end
265

266
267
268
269
      resources :services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do
        member do
          get :test
        end
270
271
      end

272
      resources :deploy_keys, constraints: {id: /\d+/} do
273
274
275
276
        member do
          put :enable
          put :disable
        end
277
278
      end

279
      resources :branches, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
280
      resources :tags, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
281
      resources :protected_branches, only: [:index, :create, :update, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
miks's avatar
miks committed
282

283
284
      resources :refs, only: [] do
        collection do
285
          get 'switch'
286
        end
gitlabhq's avatar
gitlabhq committed
287

288
289
        member do
          # tree viewer logs
290
291
          get 'logs_tree', constraints: { id: Gitlab::Regex.git_reference_regex }
          get 'logs_tree/:path' => 'refs#logs_tree',
292
293
            as: :logs_file,
            constraints: {
294
              id:   Gitlab::Regex.git_reference_regex,
295
296
297
              path: /.*/
            }
        end
gitlabhq's avatar
gitlabhq committed
298
      end
gitlabhq's avatar
gitlabhq committed
299

300
301
302
      resources :merge_requests, constraints: {id: /\d+/}, except: [:destroy] do
        member do
          get :diffs
303
          post :automerge
304
305
306
          get :automerge_check
          get :ci_status
        end
307

308
309
310
        collection do
          get :branch_from
          get :branch_to
311
          get :update_branches
312
        end
313
      end
314

315
      resources :hooks, only: [:index, :create, :destroy], constraints: {id: /\d+/} do
316
317
318
        member do
          get :test
        end
319
      end
320

321
      resources :team, controller: 'team_members', only: [:index]
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
322
323
324
      resources :milestones, except: [:destroy], constraints: {id: /\d+/} do
        member do
          put :sort_issues
325
          put :sort_merge_requests
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
326
327
        end
      end
328

329
      resources :labels, constraints: {id: /\d+/} do
330
331
332
        collection do
          post :generate
        end
333
334
      end

335
      resources :issues, constraints: {id: /\d+/}, except: [:destroy] do
336
337
338
        collection do
          post  :bulk_update
        end
Adam Leonard's avatar
Adam Leonard committed
339
      end
Robert Speicher's avatar
Robert Speicher committed
340

341
      resources :team_members, except: [:index, :edit], constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ } do
342
        collection do
343
          delete :leave
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
344

345
346
347
348
349
          # Used for import team
          # from another project
          get :import
          post :apply_import
        end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
350
351
      end

352
      resources :notes, only: [:index, :create, :destroy, :update], constraints: {id: /\d+/} do
353
        member do
354
          delete :delete_attachment
355
        end
356
      end
357

358
    end
gitlabhq's avatar
gitlabhq committed
359
  end
Robert Speicher's avatar
Robert Speicher committed
360

361
  get ':id' => 'namespaces#show', constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/}
GitLab's avatar
GitLab committed
362

363
  root to: 'dashboard#show'
gitlabhq's avatar
gitlabhq committed
364
end