Read about our upcoming Code of Conduct on this issue

routes.rb 9.93 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
  get 'search' => "search#show"
14
  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: /.*/ }

Dmitriy Zaporozhets's avatar
sidekiq    
Dmitriy Zaporozhets committed
23
24
  constraint = lambda { |request| request.env["warden"].authenticate? and request.env['warden'].user.admin? }
  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
49
50
51
  #
  # Global snippets
  #
  resources :snippets do
    member do
      get "raw"
    end
  end
Andrew8xx8's avatar
Andrew8xx8 committed
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]
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
75
    root to: "projects#trending"
76
77
  end

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

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

Robert Speicher's avatar
Robert Speicher committed
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
197
198
  devise_scope :user do
    get "/users/auth/:provider/omniauth_error" => "omniauth_callbacks#omniauth_error", as: :omniauth_error
  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
224
225
226
227
      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: /.+/}
228
      resources :network,   only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}
229
230
231
232
233
      resources :graphs,    only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/} do
        member do
          get :commits
        end
      end
234

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      resource :avatar, only: [:show, :destroy]
358
    end
gitlabhq's avatar
gitlabhq committed
359
  end
Robert Speicher's avatar
Robert Speicher committed
360

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

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