routes.rb 9.9 KB
Newer Older
D
sidekiq  
Dmitriy Zaporozhets 已提交
1
require 'sidekiq/web'
2
require 'api/api'
D
sidekiq  
Dmitriy Zaporozhets 已提交
3

G
gitlabhq 已提交
4
Gitlab::Application.routes.draw do
V
Valery Sizov 已提交
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
V
Valery Sizov 已提交
15

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

G
GitLab 已提交
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? }
D
sidekiq  
Dmitriy Zaporozhets 已提交
24
  constraints constraint do
25
    mount Sidekiq::Web, at: '/admin/sidekiq', as: :sidekiq
D
sidekiq  
Dmitriy Zaporozhets 已提交
26
  end
A
Ariejan de Vroom 已提交
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
  #
J
Job van der Voort 已提交
39 40

  get 'help'                  => 'help#index'
41
  get 'help/:category/:file'  => 'help#show', as: :help_page
M
Marin Jankovski 已提交
42
  get 'help/shortcuts'
43

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

V
Valery Sizov 已提交
54 55 56 57 58 59
  #
  # Github importer area
  #
  resource :github_import, only: [:create, :new] do
    get :status
    get :callback
60
    get :jobs
V
Valery Sizov 已提交
61 62
  end

63
  #
Y
Yatish Mehta 已提交
64
  # Explore area
65
  #
D
Dmitriy Zaporozhets 已提交
66 67 68 69
  namespace :explore do
    resources :projects, only: [:index] do
      collection do
        get :trending
70
        get :starred
D
Dmitriy Zaporozhets 已提交
71 72 73
      end
    end

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

D
Dmitriy Zaporozhets 已提交
78
  # Compatibility with old routing
79 80
  get 'public' => 'explore/projects#index'
  get 'public/projects' => 'explore/projects#index'
D
Dmitriy Zaporozhets 已提交
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
  #
N
Nihad Abbasov 已提交
90
  namespace :admin do
91
    resources :users, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do
92
      resources :keys, only: [:show, :destroy]
93
      member do
D
Dmitriy Zaporozhets 已提交
94
        put :team_update
95 96
        put :block
        put :unblock
97
        delete 'remove/:email_id', action: 'remove_email', as: 'remove_email'
D
Dmitriy Zaporozhets 已提交
98 99
      end
    end
A
Andrey Kumanyaev 已提交
100

V
Valery Sizov 已提交
101 102
    resources :applications

103 104
    resources :groups, constraints: { id: /[^\/]+/ } do
      member do
A
Andrey Kumanyaev 已提交
105
        put :project_teams_update
106
      end
A
Andrey Kumanyaev 已提交
107
    end
A
Andrey Kumanyaev 已提交
108

R
Robert Speicher 已提交
109
    resources :hooks, only: [:index, :create, :destroy] do
V
Valeriy Sizov 已提交
110 111
      get :test
    end
A
Andrey Kumanyaev 已提交
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'
G
gitlabhq 已提交
126 127
  end

R
randx 已提交
128 129 130
  #
  # Profile Area
  #
131 132 133 134
  resource :profile, only: [:show, :update] do
    member do
      get :history
      get :design
D
Dmitriy Zaporozhets 已提交
135
      get :applications
136 137 138 139

      put :reset_private_token
      put :update_username
    end
D
Dmitriy Zaporozhets 已提交
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
R
Robert Speicher 已提交
159

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

R
randx 已提交
163 164 165
  #
  # Dashboard Area
  #
166
  resource :dashboard, controller: 'dashboard', only: [:show] do
D
Dmitriy Zaporozhets 已提交
167 168 169 170 171 172
    member do
      get :projects
      get :issues
      get :merge_requests
    end
  end
G
gitlabhq 已提交
173

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

S
Steven Thonus 已提交
185
    scope module: :groups do
186
      resources :group_members, only: [:create, :update, :destroy]
S
Steven Thonus 已提交
187
      resource :avatar, only: [:destroy]
188
      resources :milestones
S
Steven Thonus 已提交
189
    end
R
randx 已提交
190 191
  end

R
Robert Speicher 已提交
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 }
G
gitlabhq 已提交
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
C
Ciro Santilli 已提交
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
S
skv 已提交
215 216
        get :diff, on: :member
      end
217 218
      resources :raw,       only: [:show], constraints: {id: /.+/}
      resources :tree,      only: [:show], constraints: {id: /.+/, format: /(html|js)/ }
S
skv-headless 已提交
219
      resources :edit_tree, only: [:show, :update], constraints: { id: /.+/ }, path: 'edit' do
C
Ciro Santilli 已提交
220
        # Cannot be GET to differentiate from GET paths that end in preview.
S
skv-headless 已提交
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

M
Marin Jankovski 已提交
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
D
Dmitriy Zaporozhets 已提交
251

252
        member do
253
          get 'history'
254
        end
V
Valery Sizov 已提交
255
      end
V
Valery Sizov 已提交
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
D
Dmitriy Zaporozhets 已提交
264
      end
265

266 267 268 269
      resources :services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do
        member do
          get :test
        end
D
Dmitriy Zaporozhets 已提交
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 }
M
miks 已提交
282

283 284
      resources :refs, only: [] do
        collection do
285
          get 'switch'
286
        end
G
gitlabhq 已提交
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
G
gitlabhq 已提交
298
      end
G
gitlabhq 已提交
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
I
Izaak Alpert 已提交
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]
D
Dmitriy Zaporozhets 已提交
322 323 324
      resources :milestones, except: [:destroy], constraints: {id: /\d+/} do
        member do
          put :sort_issues
325
          put :sort_merge_requests
D
Dmitriy Zaporozhets 已提交
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
A
Adam Leonard 已提交
339
      end
R
Robert Speicher 已提交
340

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

345 346 347 348 349
          # Used for import team
          # from another project
          get :import
          post :apply_import
        end
D
Dmitriy Zaporozhets 已提交
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
G
gitlabhq 已提交
359
  end
R
Robert Speicher 已提交
360

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

363
  root to: 'dashboard#show'
G
gitlabhq 已提交
364
end