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

Valery Sizov's avatar
Valery Sizov committed
5
Rails.application.routes.draw do
6 7 8 9 10 11 12 13 14 15 16 17 18
  if Gitlab::Sherlock.enabled?
    namespace :sherlock do
      resources :transactions, only: [:index, :show] do
        resources :queries, only: [:show]
        resources :file_samples, only: [:show]

        collection do
          delete :destroy_all
        end
      end
    end
  end

19
  if Rails.env.development?
20 21 22 23
    # Make the built-in Rails routes available in development, otherwise they'd
    # get swallowed by the `namespace/project` route matcher below.
    #
    # See https://git.io/va79N
24 25 26 27 28
    get '/rails/mailers'         => 'rails/mailers#index'
    get '/rails/mailers/:path'   => 'rails/mailers#preview'
    get '/rails/info/properties' => 'rails/info#properties'
    get '/rails/info/routes'     => 'rails/info#routes'
    get '/rails/info'            => 'rails/info#index'
29 30

    mount LetterOpenerWeb::Engine, at: '/rails/letter_opener'
31 32
  end

33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
  namespace :ci do
    # CI API
    Ci::API::API.logger Rails.logger
    mount Ci::API::API => '/api'

    resource :lint, only: [:show, :create]

    resources :projects do
      member do
        get :status, to: 'projects#badge'
        get :integration
      end
    end

    root to: 'projects#index'
  end

Valery Sizov's avatar
Valery Sizov committed
50
  use_doorkeeper do
51 52 53
    controllers applications: 'oauth/applications',
                authorized_applications: 'oauth/authorized_applications',
                authorizations: 'oauth/authorizations'
Valery Sizov's avatar
Valery Sizov committed
54
  end
55

56 57 58
  # Autocomplete
  get '/autocomplete/users' => 'autocomplete#users'
  get '/autocomplete/users/:id' => 'autocomplete#user'
59
  get '/autocomplete/projects' => 'autocomplete#projects'
60

Annabel Dunstone's avatar
Annabel Dunstone committed
61 62
  # Emojis
  resources :emojis, only: :index
63

64
  # Search
65 66
  get 'search' => 'search#show'
  get 'search/autocomplete' => 'search#autocomplete', as: :search_autocomplete
Valery Sizov's avatar
Valery Sizov committed
67

Kamil Trzcinski's avatar
Kamil Trzcinski committed
68 69 70
  # JSON Web Token
  get 'jwt/auth' => 'jwt#auth'

71
  # API
72 73
  API::API.logger Rails.logger
  mount API::API => '/api'
74

75
  constraint = lambda { |request| request.env['warden'].authenticate? and request.env['warden'].user.admin? }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
76
  constraints constraint do
77
    mount Sidekiq::Web, at: '/admin/sidekiq', as: :sidekiq
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
78
  end
Ariejan de Vroom's avatar
Ariejan de Vroom committed
79

80
  # Health check
81
  get 'health_check(/:checks)' => 'health_check#index', as: :health_check
82

83 84 85
  # Enable Grack support (for LFS only)
  mount Grack::AuthSpawner, at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\/(info\/lfs|gitlab-lfs)/.match(request.path_info) }, via: [:get, :post, :put]

86
  # Help
Job van der Voort's avatar
Job van der Voort committed
87
  get 'help'                  => 'help#index'
88
  get 'help/:category/:file'  => 'help#show', as: :help_page, constraints: { category: /.*/, file: /[^\/\.]+/ }
Marin Jankovski's avatar
Marin Jankovski committed
89
  get 'help/shortcuts'
90
  get 'help/ui' => 'help#ui'
91

Andrew8xx8's avatar
Andrew8xx8 committed
92 93 94 95 96
  #
  # Global snippets
  #
  resources :snippets do
    member do
97
      get 'raw'
Andrew8xx8's avatar
Andrew8xx8 committed
98 99
    end
  end
100

Long Nguyen's avatar
Long Nguyen committed
101
  get '/s/:username', to: redirect('/u/%{username}/snippets'),
Long Nguyen's avatar
Long Nguyen committed
102
                      constraints: { username: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ }
Andrew8xx8's avatar
Andrew8xx8 committed
103

Douwe Maan's avatar
Douwe Maan committed
104 105 106 107 108 109 110
  #
  # Invites
  #

  resources :invites, only: [:show], constraints: { id: /[A-Za-z0-9_-]+/ } do
    member do
      post :accept
Douwe Maan's avatar
Douwe Maan committed
111
      match :decline, via: [:get, :post]
Douwe Maan's avatar
Douwe Maan committed
112 113
    end
  end
114

115
  resources :sent_notifications, only: [], constraints: { id: /\h{32}/ } do
116 117 118 119 120
    member do
      get :unsubscribe
    end
  end

121 122 123
  # Spam reports
  resources :abuse_reports, only: [:new, :create]

Valery Sizov's avatar
Valery Sizov committed
124
  #
125
  # Import
Valery Sizov's avatar
Valery Sizov committed
126
  #
127 128
  namespace :import do
    resource :github, only: [:create, :new], controller: :github do
129 130 131 132 133
      get :status
      get :callback
      get :jobs
    end

134
    resource :gitlab, only: [:create, :new], controller: :gitlab do
135 136 137 138
      get :status
      get :callback
      get :jobs
    end
Marcin Kulik's avatar
Marcin Kulik committed
139

Douwe Maan's avatar
Douwe Maan committed
140 141 142 143 144
    resource :bitbucket, only: [:create, :new], controller: :bitbucket do
      get :status
      get :callback
      get :jobs
    end
145

Marcin Kulik's avatar
Marcin Kulik committed
146 147 148 149 150
    resource :gitorious, only: [:create, :new], controller: :gitorious do
      get :status
      get :callback
      get :jobs
    end
151 152 153 154 155

    resource :google_code, only: [:create, :new], controller: :google_code do
      get :status
      post :callback
      get :jobs
156 157 158

      get   :new_user_map,    path: :user_map
      post  :create_user_map, path: :user_map
159
    end
Jared Szechy's avatar
Jared Szechy committed
160 161 162 163 164 165 166 167 168

    resource :fogbugz, only: [:create, :new], controller: :fogbugz do
      get :status
      post :callback
      get :jobs

      get   :new_user_map,    path: :user_map
      post  :create_user_map, path: :user_map
    end
Valery Sizov's avatar
Valery Sizov committed
169
  end
170

171 172 173
  #
  # Uploads
  #
174

175 176
  scope path: :uploads do
    # Note attachments and User/Group/Project avatars
177 178
    get ":model/:mounted_as/:id/:filename",
        to:           "uploads#show",
179
        constraints:  { model: /note|user|group|project/, mounted_as: /avatar|attachment/, filename: /[^\/]+/ }
180

181 182 183 184 185
    # Appearance
    get ":model/:mounted_as/:id/:filename",
        to:           "uploads#show",
        constraints:  { model: /appearance/, mounted_as: /logo|header_logo/, filename: /.+/ }

186
    # Project markdown uploads
187
    get ":namespace_id/:project_id/:secret/:filename",
188
      to:           "projects/uploads#show",
189
      constraints:  { namespace_id: /[a-zA-Z.0-9_\-]+/, project_id: /[a-zA-Z.0-9_\-]+/, filename: /[^\/]+/ }
190
  end
Valery Sizov's avatar
Valery Sizov committed
191

192
  # Redirect old note attachments path to new uploads path.
193 194
  get "files/note/:id/:filename",
    to:           redirect("uploads/note/attachment/%{id}/%{filename}"),
195
    constraints:  { filename: /[^\/]+/ }
196

197
  #
Yatish Mehta's avatar
Yatish Mehta committed
198
  # Explore area
199
  #
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
200 201 202 203
  namespace :explore do
    resources :projects, only: [:index] do
      collection do
        get :trending
204
        get :starred
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
205 206 207
      end
    end

208
    resources :groups, only: [:index]
209
    resources :snippets, only: [:index]
210
    root to: 'projects#trending'
211 212
  end

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
213
  # Compatibility with old routing
214 215
  get 'public' => 'explore/projects#index'
  get 'public/projects' => 'explore/projects#index'
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
216

217 218 219
  #
  # Admin Area
  #
Nihad Abbasov's avatar
Nihad Abbasov committed
220
  namespace :admin do
221
    resources :users, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do
222
      resources :keys, only: [:show, :destroy]
223
      resources :identities, except: [:show]
224

225
      member do
226 227 228
        get :projects
        get :keys
        get :groups
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
229
        put :team_update
230 231
        put :block
        put :unblock
232
        put :unlock
233
        put :confirm
Douwe Maan's avatar
Douwe Maan committed
234
        post :impersonate
235
        patch :disable_two_factor
236
        delete 'remove/:email_id', action: 'remove_email', as: 'remove_email'
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
237 238
      end
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
239

Douwe Maan's avatar
Douwe Maan committed
240 241
    resource :impersonation, only: :destroy

242
    resources :abuse_reports, only: [:index, :destroy]
243 244
    resources :spam_logs, only: [:index, :destroy]

Valery Sizov's avatar
Valery Sizov committed
245 246
    resources :applications

247 248
    resources :groups, constraints: { id: /[^\/]+/ } do
      member do
249
        put :members_update
250
      end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
251
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
252

253
    resources :deploy_keys, only: [:index, :new, :create, :destroy]
254

255
    resources :hooks, only: [:index, :create, :destroy] do
Valeriy Sizov's avatar
Valeriy Sizov committed
256 257
      get :test
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
258

259 260 261 262
    resources :broadcast_messages, only: [:index, :edit, :create, :update, :destroy] do
      post :preview, on: :collection
    end

263
    resource :logs, only: [:show]
264
    resource :health_check, controller: 'health_check', only: [:show]
265
    resource :background_jobs, controller: 'background_jobs', only: [:show]
266

Vinnie Okada's avatar
Vinnie Okada committed
267 268 269
    resources :namespaces, path: '/projects', constraints: { id: /[a-zA-Z.0-9_\-]+/ }, only: [] do
      root to: 'projects#index', as: :projects

270 271
      resources(:projects,
                path: '/',
Vinnie Okada's avatar
Vinnie Okada committed
272 273 274 275 276 277
                constraints: { id: /[a-zA-Z.0-9_\-]+/ },
                only: [:index, :show]) do
        root to: 'projects#show'

        member do
          put :transfer
278
          post :repository_check
Vinnie Okada's avatar
Vinnie Okada committed
279
        end
280 281

        resources :runner_projects
282 283 284
      end
    end

285 286 287 288 289 290 291
    resource :appearances, path: 'appearance' do
      member do
        get :preview
        delete :logo
        delete :header_logos
      end
    end
292

293 294
    resource :application_settings, only: [:show, :update] do
      resources :services
295
      put :reset_runners_token
296
      put :reset_health_check_token
297
      put :clear_repository_check_states
298
    end
299

Valery Sizov's avatar
Valery Sizov committed
300 301
    resources :labels

302 303 304 305 306 307 308 309 310 311 312 313 314
    resources :runners, only: [:index, :show, :update, :destroy] do
      member do
        get :resume
        get :pause
      end
    end

    resources :builds, only: :index do
      collection do
        post :cancel_all
      end
    end

315
    root to: 'dashboard#index'
gitlabhq's avatar
gitlabhq committed
316 317
  end

randx's avatar
randx committed
318 319 320
  #
  # Profile Area
  #
321 322
  resource :profile, only: [:show, :update] do
    member do
323
      get :audit_log
324
      get :applications, to: 'oauth/applications#index'
325 326 327 328

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

330
    scope module: :profiles do
331 332 333 334 335
      resource :account, only: [:show, :update] do
        member do
          delete :unlink
        end
      end
336
      resource :notifications, only: [:show, :update]
337 338 339 340 341
      resource :password, only: [:new, :create, :edit, :update] do
        member do
          put :reset
        end
      end
342
      resource :preferences, only: [:show, :update]
343
      resources :keys
344
      resources :emails, only: [:index, :create, :destroy]
345
      resource :avatar, only: [:destroy]
346
      resource :two_factor_auth, only: [:show, :create, :destroy] do
347
        member do
348
          post :create_u2f
349
          post :codes
350
          patch :skip
351 352
        end
      end
353
    end
354
  end
355

Long Nguyen's avatar
Long Nguyen committed
356
  scope(path: 'u/:username',
Long Nguyen's avatar
Long Nguyen committed
357
        as: :user,
Long Nguyen's avatar
Long Nguyen committed
358 359
        constraints: { username: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ },
        controller: :users) do
Long Nguyen's avatar
Long Nguyen committed
360 361 362 363 364 365 366
    get :calendar
    get :calendar_activities
    get :groups
    get :projects
    get :contributed, as: :contributed_projects
    get :snippets
    get '/', action: :show
Long Nguyen's avatar
Long Nguyen committed
367
  end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
368

randx's avatar
randx committed
369 370 371
  #
  # Dashboard Area
  #
372 373 374 375
  resource :dashboard, controller: 'dashboard', only: [] do
    get :issues
    get :merge_requests
    get :activity
Douwe Maan's avatar
Douwe Maan committed
376 377 378

    scope module: :dashboard do
      resources :milestones, only: [:index, :show]
379
      resources :labels, only: [:index]
380

381
      resources :groups, only: [:index]
382
      resources :snippets, only: [:index]
383 384 385 386 387 388

      resources :todos, only: [:index, :destroy] do
        collection do
          delete :destroy_all
        end
      end
389

390
      resources :projects, only: [:index] do
391 392 393 394
        collection do
          get :starred
        end
      end
Douwe Maan's avatar
Douwe Maan committed
395
    end
396 397

    root to: "dashboard/projects#index"
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
398
  end
gitlabhq's avatar
gitlabhq committed
399

randx's avatar
randx committed
400 401 402
  #
  # Groups Area
  #
403
  resources :groups, constraints: { id: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ }  do
randx's avatar
randx committed
404 405 406
    member do
      get :issues
      get :merge_requests
407
      get :projects
408
      get :activity
randx's avatar
randx committed
409
    end
410

Steven Thonus's avatar
Steven Thonus committed
411
    scope module: :groups do
412
      resources :group_members, only: [:index, :create, :update, :destroy] do
413
        post :resend_invite, on: :member
414
        delete :leave, on: :collection
415
      end
416

Steven Thonus's avatar
Steven Thonus committed
417
      resource :avatar, only: [:destroy]
418
      resources :milestones, constraints: { id: /[^\/]+/ }, only: [:index, :show, :update, :new, :create]
419
      resource :notification_setting, only: [:update]
Steven Thonus's avatar
Steven Thonus committed
420
    end
randx's avatar
randx committed
421 422
  end

423
  resources :projects, constraints: { id: /[^\/]+/ }, only: [:index, :new, :create]
424

425 426 427 428 429
  devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks,
                                    registrations: :registrations,
                                    passwords: :passwords,
                                    sessions: :sessions,
                                    confirmations: :confirmations }
gitlabhq's avatar
gitlabhq committed
430

431
  devise_scope :user do
432
    get '/users/auth/:provider/omniauth_error' => 'omniauth_callbacks#omniauth_error', as: :omniauth_error
Phil Hughes's avatar
Phil Hughes committed
433
    get '/users/almost_there' => 'confirmations#almost_there'
434
  end
Vinnie Okada's avatar
Vinnie Okada committed
435

436
  root to: "root#index"
Vinnie Okada's avatar
Vinnie Okada committed
437

438 439 440
  #
  # Project Area
  #
Vinnie Okada's avatar
Vinnie Okada committed
441
  resources :namespaces, path: '/', constraints: { id: /[a-zA-Z.0-9_\-]+/ }, only: [] do
442
    resources(:projects, constraints: { id: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ }, except:
Vinnie Okada's avatar
Vinnie Okada committed
443
              [:new, :create, :index], path: "/") do
444

Vinnie Okada's avatar
Vinnie Okada committed
445 446
      member do
        put :transfer
447
        delete :remove_fork
Vinnie Okada's avatar
Vinnie Okada committed
448 449
        post :archive
        post :unarchive
450
        post :housekeeping
Vinnie Okada's avatar
Vinnie Okada committed
451 452 453
        post :toggle_star
        post :markdown_preview
        get :autocomplete_sources
454
        get :activity
skv's avatar
skv committed
455
      end
456

Vinnie Okada's avatar
Vinnie Okada committed
457
      scope module: :projects do
458
        # Git HTTP clients ('git clone' etc.)
459
        scope constraints: { id: /.+\.git/, format: nil } do
Jacob Vosmaer's avatar
Jacob Vosmaer committed
460 461 462
          get '/info/refs', to: 'git_http#info_refs'
          post '/git-upload-pack', to: 'git_http#git_upload_pack'
          post '/git-receive-pack', to: 'git_http#git_receive_pack'
463 464
        end

465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480
        # Allow /info/refs, /info/refs?service=git-upload-pack, and
        # /info/refs?service=git-receive-pack, but nothing else.
        #
        git_http_handshake = lambda do |request|
          request.query_string.blank? ||
            request.query_string.match(/\Aservice=git-(upload|receive)-pack\z/)
        end

        ref_redirect = redirect do |params, request|
          path = "#{params[:namespace_id]}/#{params[:project_id]}.git/info/refs"
          path << "?#{request.query_string}" unless request.query_string.blank?
          path
        end

        get '/info/refs', constraints: git_http_handshake, to: ref_redirect

Vinnie Okada's avatar
Vinnie Okada committed
481 482 483 484 485 486 487 488
        # Blob routes:
        get '/new/*id', to: 'blob#new', constraints: { id: /.+/ }, as: 'new_blob'
        post '/create/*id', to: 'blob#create', constraints: { id: /.+/ }, as: 'create_blob'
        get '/edit/*id', to: 'blob#edit', constraints: { id: /.+/ }, as: 'edit_blob'
        put '/update/*id', to: 'blob#update', constraints: { id: /.+/ }, as: 'update_blob'
        post '/preview/*id', to: 'blob#preview', constraints: { id: /.+/ }, as: 'preview_blob'

        scope do
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505
          get(
            '/blob/*id/diff',
            to: 'blob#diff',
            constraints: { id: /.+/, format: false },
            as: :blob_diff
          )
          get(
            '/blob/*id',
            to: 'blob#show',
            constraints: { id: /.+/, format: false },
            as: :blob
          )
          delete(
            '/blob/*id',
            to: 'blob#destroy',
            constraints: { id: /.+/, format: false }
          )
506 507 508 509 510 511 512 513 514 515
          put(
            '/blob/*id',
            to: 'blob#update',
            constraints: { id: /.+/, format: false }
          )
          post(
            '/blob/*id',
            to: 'blob#create',
            constraints: { id: /.+/, format: false }
          )
Vinnie Okada's avatar
Vinnie Okada committed
516
        end
517

Vinnie Okada's avatar
Vinnie Okada committed
518 519 520 521 522 523 524
        scope do
          get(
            '/raw/*id',
            to: 'raw#show',
            constraints: { id: /.+/, format: /(html|js)/ },
            as: :raw
          )
525
        end
526

Vinnie Okada's avatar
Vinnie Okada committed
527 528 529 530 531 532 533 534 535
        scope do
          get(
            '/tree/*id',
            to: 'tree#show',
            constraints: { id: /.+/, format: /(html|js)/ },
            as: :tree
          )
        end

536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553
        scope do
          get(
            '/find_file/*id',
            to: 'find_file#show',
            constraints: { id: /.+/, format: /html/ },
            as: :find_file
          )
        end

        scope do
          get(
            '/files/*id',
            to: 'find_file#list',
            constraints: { id: /(?:[^.]|\.(?!json$))+/, format: /json/ },
            as: :files
          )
        end

Stan Hu's avatar
Stan Hu committed
554 555
        scope do
          post(
Gabriel Mazetto's avatar
Gabriel Mazetto committed
556
            '/create_dir/*id',
Stan Hu's avatar
Stan Hu committed
557 558 559 560 561 562
              to: 'tree#create_dir',
              constraints: { id: /.+/ },
              as: 'create_dir'
          )
        end

Vinnie Okada's avatar
Vinnie Okada committed
563 564 565 566 567 568 569
        scope do
          get(
            '/blame/*id',
            to: 'blame#show',
            constraints: { id: /.+/, format: /(html|js)/ },
            as: :blame
          )
570
        end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
571

572 573 574 575
        scope do
          get(
            '/commits/*id',
            to: 'commits#show',
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
576
            constraints: { id: /(?:[^.]|\.(?!atom$))+/, format: /atom/ },
577 578 579 580 581
            as: :commits
          )
        end

        resource  :avatar, only: [:show, :destroy]
582
        resources :commit, only: [:show], constraints: { id: /\h{7,40}/ } do
583 584
          member do
            get :branches
Kamil Trzcinski's avatar
Kamil Trzcinski committed
585 586 587
            get :builds
            post :cancel_builds
            post :retry_builds
588
            post :revert
589
            post :cherry_pick
590
          end
591 592 593 594 595 596
        end

        resources :compare, only: [:index, :create]
        resources :network, only: [:show], constraints: { id: /(?:[^.]|\.(?!json$))+/, format: /json/ }

        resources :graphs, only: [:show], constraints: { id: /(?:[^.]|\.(?!json$))+/, format: /json/ } do
Vinnie Okada's avatar
Vinnie Okada committed
597 598
          member do
            get :commits
599
            get :ci
600
            get :languages
Vinnie Okada's avatar
Vinnie Okada committed
601
          end
602
        end
603

Vinnie Okada's avatar
Vinnie Okada committed
604 605
        get '/compare/:from...:to' => 'compare#show', :as => 'compare',
            :constraints => { from: /.+/, to: /.+/ }
606

Vinnie Okada's avatar
Vinnie Okada committed
607 608 609 610
        resources :snippets, constraints: { id: /\d+/ } do
          member do
            get 'raw'
          end
611
        end
612

613
        WIKI_SLUG_ID = { id: /\S+/ } unless defined? WIKI_SLUG_ID
614

Stan Hu's avatar
Stan Hu committed
615 616 617 618 619 620 621 622 623 624 625 626
        scope do
          # Order matters to give priority to these matches
          get '/wikis/git_access', to: 'wikis#git_access'
          get '/wikis/pages', to: 'wikis#pages', as: 'wiki_pages'
          post '/wikis', to: 'wikis#create'

          get '/wikis/*id/history', to: 'wikis#history', as: 'wiki_history', constraints: WIKI_SLUG_ID
          get '/wikis/*id/edit', to: 'wikis#edit', as: 'wiki_edit', constraints: WIKI_SLUG_ID

          get '/wikis/*id', to: 'wikis#show', as: 'wiki', constraints: WIKI_SLUG_ID
          delete '/wikis/*id', to: 'wikis#destroy', constraints: WIKI_SLUG_ID
          put '/wikis/*id', to: 'wikis#update', constraints: WIKI_SLUG_ID
627
          post '/wikis/*id/markdown_preview', to:'wikis#markdown_preview', constraints: WIKI_SLUG_ID, as: 'wiki_markdown_preview'
628
        end
629

Vinnie Okada's avatar
Vinnie Okada committed
630 631 632 633 634
        resource :repository, only: [:show, :create] do
          member do
            get 'archive', constraints: { format: Gitlab::Regex.archive_formats_regex }
          end
        end
miks's avatar
miks committed
635

Vinnie Okada's avatar
Vinnie Okada committed
636 637 638 639
        resources :services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do
          member do
            get :test
          end
640
        end
gitlabhq's avatar
gitlabhq committed
641

642
        resources :deploy_keys, constraints: { id: /\d+/ }, only: [:index, :new, :create] do
Vinnie Okada's avatar
Vinnie Okada committed
643 644 645 646
          member do
            put :enable
            put :disable
          end
647
        end
gitlabhq's avatar
gitlabhq committed
648

649
        resources :forks, only: [:index, :new, :create]
Vinnie Okada's avatar
Vinnie Okada committed
650
        resource :import, only: [:new, :create, :show]
651
        resource :notification_setting, only: [:update]
Vinnie Okada's avatar
Vinnie Okada committed
652 653 654 655 656 657 658 659 660

        resources :refs, only: [] do
          collection do
            get 'switch'
          end

          member do
            # tree viewer logs
            get 'logs_tree', constraints: { id: Gitlab::Regex.git_reference_regex }
661 662
            # Directories with leading dots erroneously get rejected if git
            # ref regex used in constraints. Regex verification now done in controller.
663
            get 'logs_tree/*path' => 'refs#logs_tree', as: :logs_file, constraints: {
664
              id: /.*/,
Vinnie Okada's avatar
Vinnie Okada committed
665 666 667
              path: /.*/
            }
          end
668
        end
669

670
        resources :merge_requests, constraints: { id: /\d+/ } do
Vinnie Okada's avatar
Vinnie Okada committed
671
          member do
672
            get :commits
Vinnie Okada's avatar
Vinnie Okada committed
673
            get :diffs
674
            get :builds
675 676
            get :merge_check
            post :merge
677
            post :cancel_merge_when_build_succeeds
Vinnie Okada's avatar
Vinnie Okada committed
678
            get :ci_status
Valery Sizov's avatar
tests  
Valery Sizov committed
679
            post :toggle_subscription
680
            post :toggle_award_emoji
681
            post :remove_wip
Vinnie Okada's avatar
Vinnie Okada committed
682 683 684 685 686 687 688
          end

          collection do
            get :branch_from
            get :branch_to
            get :update_branches
          end
689
        end
690

Vinnie Okada's avatar
Vinnie Okada committed
691
        resources :branches, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
692 693
        resources :tags, only: [:index, :show, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex } do
          resource :release, only: [:edit, :update]
694 695
        end

Vinnie Okada's avatar
Vinnie Okada committed
696
        resources :protected_branches, only: [:index, :create, :update, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
Phil Hughes's avatar
Phil Hughes committed
697
        resources :variables, only: [:index, :show, :update, :create, :destroy]
698
        resources :triggers, only: [:index, :create, :destroy]
699

Kamil Trzcinski's avatar
Kamil Trzcinski committed
700
        resources :pipelines, only: [:index, :new, :create, :show] do
Kamil Trzcinski's avatar
WIP  
Kamil Trzcinski committed
701 702 703 704 705 706
          member do
            post :cancel
            post :retry
          end
        end

Kamil Trzcinski's avatar
Kamil Trzcinski committed
707 708
        resources :environments, only: [:index, :show]

709
        resources :builds, only: [:index, :show], constraints: { id: /\d+/ } do
Kamil Trzcinski's avatar
Kamil Trzcinski committed
710
          collection do
Kamil Trzcinski's avatar
Kamil Trzcinski committed
711
            post :cancel_all
Kamil Trzcinski's avatar
Kamil Trzcinski committed
712 713
          end

714 715
          member do
            get :status
716
            post :cancel
717
            post :retry
718
            post :erase
719
            get :trace
720
            get :raw
721
          end
722

723 724
          resource :artifacts, only: [] do
            get :download
725 726
            get :browse, path: 'browse(/*path)', format: false
            get :file, path: 'file/*path', format: false
727
          end
728
        end
729

Vinnie Okada's avatar
Vinnie Okada committed
730 731 732 733
        resources :hooks, only: [:index, :create, :destroy], constraints: { id: /\d+/ } do
          member do
            get :test
          end
734
        end
735

Kamil Trzcinski's avatar
WIP  
Kamil Trzcinski committed
736
        resources :container_registry, only: [:index, :destroy], constraints: { id: Gitlab::Regex.container_registry_reference_regex }
737

738
        resources :milestones, constraints: { id: /\d+/ } do
Vinnie Okada's avatar
Vinnie Okada committed
739 740 741 742
          member do
            put :sort_issues
            put :sort_merge_requests
          end
743
        end
744

Vinnie Okada's avatar
Vinnie Okada committed
745 746 747
        resources :labels, constraints: { id: /\d+/ } do
          collection do
            post :generate
Alfredo Sumaran's avatar
Alfredo Sumaran committed
748
            post :set_priorities
Vinnie Okada's avatar
Vinnie Okada committed
749
          end
750 751 752

          member do
            post :toggle_subscription
753
            delete :remove_priority
754
          end
755
        end
756

757
        resources :issues, constraints: { id: /\d+/ } do
Valery Sizov's avatar
Valery Sizov committed
758
          member do
Valery Sizov's avatar
tests  
Valery Sizov committed
759
            post :toggle_subscription
760
            post :toggle_award_emoji
761 762
            get :referenced_merge_requests
            get :related_branches
763
            get :can_create_branch
Valery Sizov's avatar
Valery Sizov committed
764
          end
Vinnie Okada's avatar
Vinnie Okada committed
765 766 767
          collection do
            post  :bulk_update
          end
768
        end
Robert Speicher's avatar
Robert Speicher committed
769

770
        resources :project_members, except: [:new, :edit], constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ } do
Vinnie Okada's avatar
Vinnie Okada committed
771 772
          collection do
            delete :leave
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
773

Vinnie Okada's avatar
Vinnie Okada committed
774 775 776 777 778
            # Used for import team
            # from another project
            get :import
            post :apply_import
          end
779 780 781 782

          member do
            post :resend_invite
          end
783
        end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
784

785 786
        resources :group_links, only: [:index, :create, :destroy], constraints: { id: /\d+/ }

Vinnie Okada's avatar
Vinnie Okada committed
787 788
        resources :notes, only: [:index, :create, :destroy, :update], constraints: { id: /\d+/ } do
          member do
Fatih Acet's avatar
Fatih Acet committed
789
            post :toggle_award_emoji
Vinnie Okada's avatar
Vinnie Okada committed
790 791
            delete :delete_attachment
          end
792
        end
793 794 795

        resources :uploads, only: [:create] do
          collection do
796
            get ":secret/:filename", action: :show, as: :show, constraints: { filename: /[^\/]+/ }
797
          end
798
        end
799

800 801 802 803 804
        resources :runners, only: [:index, :edit, :update, :destroy, :show] do
          member do
            get :resume
            get :pause
          end
805 806 807 808

          collection do
            post :toggle_shared_runners
          end
809
        end
810 811

        resources :runner_projects, only: [:create, :destroy]
812
        resources :badges, only: [:index] do
813
          collection do
814 815 816
            scope '*ref', constraints: { ref: Gitlab::Regex.git_reference_regex } do
              get :build, constraints: { format: /svg/ }
            end
817 818
          end
        end
819
      end
820
    end
gitlabhq's avatar
gitlabhq committed
821
  end
822

823
  # Get all keys of user
824
  get ':username.keys' => 'profiles/keys#get_keys', constraints: { username: /.*/ }
825

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