routes.rb 21.1 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 20 21 22 23 24 25 26 27 28 29 30
  # 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
  if Rails.env.development?
    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'
  end

31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
  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
48
  use_doorkeeper do
49 50 51
    controllers applications: 'oauth/applications',
                authorized_applications: 'oauth/authorized_applications',
                authorizations: 'oauth/authorizations'
Valery Sizov's avatar
Valery Sizov committed
52
  end
53

54 55 56 57
  # Autocomplete
  get '/autocomplete/users' => 'autocomplete#users'
  get '/autocomplete/users/:id' => 'autocomplete#user'

Annabel Dunstone's avatar
Annabel Dunstone committed
58 59
  # Emojis
  resources :emojis, only: :index
60

61
  # Search
62 63
  get 'search' => 'search#show'
  get 'search/autocomplete' => 'search#autocomplete', as: :search_autocomplete
Valery Sizov's avatar
Valery Sizov committed
64

65
  # API
66 67
  API::API.logger Rails.logger
  mount API::API => '/api'
68

69
  constraint = lambda { |request| request.env['warden'].authenticate? and request.env['warden'].user.admin? }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
70
  constraints constraint do
71
    mount Sidekiq::Web, at: '/admin/sidekiq', as: :sidekiq
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
72
  end
Ariejan de Vroom's avatar
Ariejan de Vroom committed
73

74
  # Enable Grack support
Marin Jankovski's avatar
Marin Jankovski committed
75
  mount Grack::AuthSpawner, at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) }, via: [:get, :post, :put]
76

77
  # Help
Job van der Voort's avatar
Job van der Voort committed
78
  get 'help'                  => 'help#index'
79
  get 'help/:category/:file'  => 'help#show', as: :help_page, constraints: { category: /.*/, file: /[^\/\.]+/ }
Marin Jankovski's avatar
Marin Jankovski committed
80
  get 'help/shortcuts'
81
  get 'help/ui'               => 'help#ui'
82

Andrew8xx8's avatar
Andrew8xx8 committed
83 84 85 86 87
  #
  # Global snippets
  #
  resources :snippets do
    member do
88
      get 'raw'
Andrew8xx8's avatar
Andrew8xx8 committed
89 90
    end
  end
91

Douwe Maan's avatar
Douwe Maan committed
92 93 94 95 96 97 98
  #
  # Invites
  #

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

103
  resources :sent_notifications, only: [], constraints: { id: /\h{32}/ } do
104 105 106 107 108
    member do
      get :unsubscribe
    end
  end

109 110 111
  # Spam reports
  resources :abuse_reports, only: [:new, :create]

Valery Sizov's avatar
Valery Sizov committed
112
  #
113
  # Import
Valery Sizov's avatar
Valery Sizov committed
114
  #
115 116
  namespace :import do
    resource :github, only: [:create, :new], controller: :github do
Valery Sizov's avatar
Valery Sizov committed
117 118 119 120 121
      get :status
      get :callback
      get :jobs
    end

122
    resource :gitlab, only: [:create, :new], controller: :gitlab do
Valery Sizov's avatar
Valery Sizov committed
123 124 125 126
      get :status
      get :callback
      get :jobs
    end
Marcin Kulik's avatar
Marcin Kulik committed
127

Douwe Maan's avatar
Douwe Maan committed
128 129 130 131 132
    resource :bitbucket, only: [:create, :new], controller: :bitbucket do
      get :status
      get :callback
      get :jobs
    end
133

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

    resource :google_code, only: [:create, :new], controller: :google_code do
      get :status
      post :callback
      get :jobs
144 145 146

      get   :new_user_map,    path: :user_map
      post  :create_user_map, path: :user_map
147
    end
Jared Szechy's avatar
Jared Szechy committed
148 149 150 151 152 153 154 155 156

    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
157
  end
158

159 160 161
  #
  # Uploads
  #
162

163 164
  scope path: :uploads do
    # Note attachments and User/Group/Project avatars
165 166
    get ":model/:mounted_as/:id/:filename",
        to:           "uploads#show",
167
        constraints:  { model: /note|user|group|project/, mounted_as: /avatar|attachment/, filename: /[^\/]+/ }
168

169 170 171 172 173
    # Appearance
    get ":model/:mounted_as/:id/:filename",
        to:           "uploads#show",
        constraints:  { model: /appearance/, mounted_as: /logo|header_logo/, filename: /.+/ }

174
    # Project markdown uploads
175
    get ":namespace_id/:project_id/:secret/:filename",
176
      to:           "projects/uploads#show",
177
      constraints:  { namespace_id: /[a-zA-Z.0-9_\-]+/, project_id: /[a-zA-Z.0-9_\-]+/, filename: /[^\/]+/ }
178
  end
Valery Sizov's avatar
Valery Sizov committed
179

180
  # Redirect old note attachments path to new uploads path.
181 182
  get "files/note/:id/:filename",
    to:           redirect("uploads/note/attachment/%{id}/%{filename}"),
183
    constraints:  { filename: /[^\/]+/ }
184

185
  #
Yatish Mehta's avatar
Yatish Mehta committed
186
  # Explore area
187
  #
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
188 189 190 191
  namespace :explore do
    resources :projects, only: [:index] do
      collection do
        get :trending
192
        get :starred
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
193 194 195
      end
    end

196
    resources :groups, only: [:index]
197
    resources :snippets, only: [:index]
198
    root to: 'projects#trending'
199 200
  end

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
201
  # Compatibility with old routing
202 203
  get 'public' => 'explore/projects#index'
  get 'public/projects' => 'explore/projects#index'
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
204

205 206 207
  #
  # Admin Area
  #
Nihad Abbasov's avatar
Nihad Abbasov committed
208
  namespace :admin do
209
    resources :users, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do
210
      resources :keys, only: [:show, :destroy]
211
      resources :identities, except: [:show]
212

213
      delete 'stop_impersonation' => 'impersonation#destroy', on: :collection
214

215
      member do
216 217 218
        get :projects
        get :keys
        get :groups
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
219
        put :team_update
220 221
        put :block
        put :unblock
222
        put :unlock
223
        put :confirm
224
        post 'impersonate' => 'impersonation#create'
225
        patch :disable_two_factor
226
        delete 'remove/:email_id', action: 'remove_email', as: 'remove_email'
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
227 228
      end
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
229

230
    resources :abuse_reports, only: [:index, :destroy]
231 232
    resources :spam_logs, only: [:index, :destroy]

Valery Sizov's avatar
Valery Sizov committed
233 234
    resources :applications

235 236
    resources :groups, constraints: { id: /[^\/]+/ } do
      member do
237
        put :members_update
238
      end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
239
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
240

241
    resources :deploy_keys, only: [:index, :new, :create, :destroy]
242

243
    resources :hooks, only: [:index, :create, :destroy] do
Valeriy Sizov's avatar
Valeriy Sizov committed
244 245
      get :test
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
246

247 248 249 250
    resources :broadcast_messages, only: [:index, :edit, :create, :update, :destroy] do
      post :preview, on: :collection
    end

251
    resource :logs, only: [:show]
252
    resource :background_jobs, controller: 'background_jobs', only: [:show]
253

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

257 258
      resources(:projects,
                path: '/',
Vinnie Okada's avatar
Vinnie Okada committed
259 260 261 262 263 264
                constraints: { id: /[a-zA-Z.0-9_\-]+/ },
                only: [:index, :show]) do
        root to: 'projects#show'

        member do
          put :transfer
265
          post :repository_check
Vinnie Okada's avatar
Vinnie Okada committed
266
        end
267 268

        resources :runner_projects
269 270 271
      end
    end

272 273 274 275 276 277 278
    resource :appearances, path: 'appearance' do
      member do
        get :preview
        delete :logo
        delete :header_logos
      end
    end
279

280 281
    resource :application_settings, only: [:show, :update] do
      resources :services
282
      put :reset_runners_token
283
      put :clear_repository_check_states
284
    end
285

Valery Sizov's avatar
Valery Sizov committed
286 287
    resources :labels

288 289 290 291 292 293 294 295 296 297 298 299 300
    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

301
    root to: 'dashboard#index'
gitlabhq's avatar
gitlabhq committed
302 303
  end

randx's avatar
randx committed
304 305 306
  #
  # Profile Area
  #
307 308
  resource :profile, only: [:show, :update] do
    member do
309
      get :audit_log
310
      get :applications, to: 'oauth/applications#index'
311 312 313 314

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

316
    scope module: :profiles do
317 318 319 320 321
      resource :account, only: [:show, :update] do
        member do
          delete :unlink
        end
      end
322
      resource :notifications, only: [:show, :update]
323 324 325 326 327
      resource :password, only: [:new, :create, :edit, :update] do
        member do
          put :reset
        end
      end
328
      resource :preferences, only: [:show, :update]
329
      resources :keys
330
      resources :emails, only: [:index, :create, :destroy]
331
      resource :avatar, only: [:destroy]
332 333
      resource :two_factor_auth, only: [:new, :create, :destroy] do
        member do
334
          post :codes
335
          patch :skip
336 337
        end
      end
338
    end
339
  end
340

341
  get 'u/:username/calendar' => 'users#calendar', as: :user_calendar,
342 343 344 345
      constraints: { username: /.*/ }

  get 'u/:username/calendar_activities' => 'users#calendar_activities', as: :user_calendar_activities,
      constraints: { username: /.*/ }
346

347 348 349
  get 'u/:username/groups' => 'users#groups', as: :user_groups,
      constraints: { username: /.*/ }

350
  get 'u/:username/projects' => 'users#projects', as: :user_projects,
351 352
      constraints: { username: /.*/ }

353
  get 'u/:username/contributed' => 'users#contributed', as: :user_contributed_projects,
354 355
      constraints: { username: /.*/ }

356 357 358
  get 'u/:username/snippets' => 'users#snippets', as: :user_snippets,
      constraints: { username: /.*/ }

359
  get '/u/:username' => 'users#show', as: :user,
360
      constraints: { username: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
361

randx's avatar
randx committed
362 363 364
  #
  # Dashboard Area
  #
365 366 367 368
  resource :dashboard, controller: 'dashboard', only: [] do
    get :issues
    get :merge_requests
    get :activity
Douwe Maan's avatar
Douwe Maan committed
369 370 371

    scope module: :dashboard do
      resources :milestones, only: [:index, :show]
372
      resources :labels, only: [:index]
373

374
      resources :groups, only: [:index]
375
      resources :snippets, only: [:index]
376 377 378 379 380 381

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

383
      resources :projects, only: [:index] do
384 385 386 387
        collection do
          get :starred
        end
      end
Douwe Maan's avatar
Douwe Maan committed
388
    end
389 390

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

randx's avatar
randx committed
393 394 395
  #
  # Groups Area
  #
396
  resources :groups, constraints: { id: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ }  do
randx's avatar
randx committed
397 398 399
    member do
      get :issues
      get :merge_requests
400
      get :projects
401
      get :activity
randx's avatar
randx committed
402
    end
403

Steven Thonus's avatar
Steven Thonus committed
404
    scope module: :groups do
405
      resources :group_members, only: [:index, :create, :update, :destroy] do
406
        post :resend_invite, on: :member
407
        delete :leave, on: :collection
408
      end
409

Steven Thonus's avatar
Steven Thonus committed
410
      resource :avatar, only: [:destroy]
411
      resources :milestones, constraints: { id: /[^\/]+/ }, only: [:index, :show, :update, :new, :create]
412
      resource :notification_setting, only: [:update]
Steven Thonus's avatar
Steven Thonus committed
413
    end
randx's avatar
randx committed
414 415
  end

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

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

420
  devise_scope :user do
421
    get '/users/auth/:provider/omniauth_error' => 'omniauth_callbacks#omniauth_error', as: :omniauth_error
Phil Hughes's avatar
Phil Hughes committed
422
    get '/users/almost_there' => 'confirmations#almost_there'
423
  end
Vinnie Okada's avatar
Vinnie Okada committed
424

425
  root to: "root#index"
Vinnie Okada's avatar
Vinnie Okada committed
426

427 428 429
  #
  # Project Area
  #
Vinnie Okada's avatar
Vinnie Okada committed
430
  resources :namespaces, path: '/', constraints: { id: /[a-zA-Z.0-9_\-]+/ }, only: [] do
431
    resources(:projects, constraints: { id: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ }, except:
Vinnie Okada's avatar
Vinnie Okada committed
432 433 434
              [:new, :create, :index], path: "/") do
      member do
        put :transfer
435
        delete :remove_fork
Vinnie Okada's avatar
Vinnie Okada committed
436 437
        post :archive
        post :unarchive
438
        post :housekeeping
Vinnie Okada's avatar
Vinnie Okada committed
439 440 441
        post :toggle_star
        post :markdown_preview
        get :autocomplete_sources
442
        get :activity
skv's avatar
skv committed
443
      end
444

Vinnie Okada's avatar
Vinnie Okada committed
445 446 447 448 449 450 451 452 453
      scope module: :projects do
        # 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
454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470
          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 }
          )
471 472 473 474 475 476 477 478 479 480
          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
481
        end
482

Vinnie Okada's avatar
Vinnie Okada committed
483 484 485 486 487 488 489
        scope do
          get(
            '/raw/*id',
            to: 'raw#show',
            constraints: { id: /.+/, format: /(html|js)/ },
            as: :raw
          )
490
        end
491

Vinnie Okada's avatar
Vinnie Okada committed
492 493 494 495 496 497 498 499 500
        scope do
          get(
            '/tree/*id',
            to: 'tree#show',
            constraints: { id: /.+/, format: /(html|js)/ },
            as: :tree
          )
        end

501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518
        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
519 520
        scope do
          post(
Gabriel Mazetto's avatar
Gabriel Mazetto committed
521
            '/create_dir/*id',
Stan Hu's avatar
Stan Hu committed
522 523 524 525 526 527
              to: 'tree#create_dir',
              constraints: { id: /.+/ },
              as: 'create_dir'
          )
        end

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

537 538 539 540
        scope do
          get(
            '/commits/*id',
            to: 'commits#show',
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
541
            constraints: { id: /(?:[^.]|\.(?!atom$))+/, format: /atom/ },
542 543 544 545 546
            as: :commits
          )
        end

        resource  :avatar, only: [:show, :destroy]
547
        resources :commit, only: [:show], constraints: { id: /\h{7,40}/ } do
548 549
          member do
            get :branches
Kamil Trzcinski's avatar
Kamil Trzcinski committed
550 551 552
            get :builds
            post :cancel_builds
            post :retry_builds
553
            post :revert
554
            post :cherry_pick
555
          end
556 557 558 559 560 561
        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
562 563
          member do
            get :commits
564
            get :ci
565
            get :languages
Vinnie Okada's avatar
Vinnie Okada committed
566
          end
567
        end
568

Vinnie Okada's avatar
Vinnie Okada committed
569 570
        get '/compare/:from...:to' => 'compare#show', :as => 'compare',
            :constraints => { from: /.+/, to: /.+/ }
571

Vinnie Okada's avatar
Vinnie Okada committed
572 573 574 575
        resources :snippets, constraints: { id: /\d+/ } do
          member do
            get 'raw'
          end
576
        end
577

578
        WIKI_SLUG_ID = { id: /\S+/ } unless defined? WIKI_SLUG_ID
579

Stan Hu's avatar
Stan Hu committed
580 581 582 583
        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'
584
          post '/wikis/markdown_preview', to:'wikis#markdown_preview'
Stan Hu's avatar
Stan Hu committed
585 586 587 588 589 590 591 592
          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
593
        end
594

Vinnie Okada's avatar
Vinnie Okada committed
595 596 597 598 599
        resource :repository, only: [:show, :create] do
          member do
            get 'archive', constraints: { format: Gitlab::Regex.archive_formats_regex }
          end
        end
miks's avatar
miks committed
600

Vinnie Okada's avatar
Vinnie Okada committed
601 602 603 604
        resources :services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do
          member do
            get :test
          end
605
        end
gitlabhq's avatar
gitlabhq committed
606

607
        resources :deploy_keys, constraints: { id: /\d+/ }, only: [:index, :new, :create] do
Vinnie Okada's avatar
Vinnie Okada committed
608 609 610 611
          member do
            put :enable
            put :disable
          end
612
        end
gitlabhq's avatar
gitlabhq committed
613

614
        resources :forks, only: [:index, :new, :create]
Vinnie Okada's avatar
Vinnie Okada committed
615
        resource :import, only: [:new, :create, :show]
616
        resource :notification_setting, only: [:update]
Vinnie Okada's avatar
Vinnie Okada committed
617 618 619 620 621 622 623 624 625

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

          member do
            # tree viewer logs
            get 'logs_tree', constraints: { id: Gitlab::Regex.git_reference_regex }
626 627
            # Directories with leading dots erroneously get rejected if git
            # ref regex used in constraints. Regex verification now done in controller.
628
            get 'logs_tree/*path' => 'refs#logs_tree', as: :logs_file, constraints: {
629
              id: /.*/,
Vinnie Okada's avatar
Vinnie Okada committed
630 631 632
              path: /.*/
            }
          end
633
        end
634

635
        resources :merge_requests, constraints: { id: /\d+/ } do
Vinnie Okada's avatar
Vinnie Okada committed
636
          member do
637
            get :commits
Vinnie Okada's avatar
Vinnie Okada committed
638
            get :diffs
639
            get :builds
640 641
            get :merge_check
            post :merge
642
            post :cancel_merge_when_build_succeeds
Vinnie Okada's avatar
Vinnie Okada committed
643
            get :ci_status
Valery Sizov's avatar
tests  
Valery Sizov committed
644
            post :toggle_subscription
645
            post :remove_wip
Vinnie Okada's avatar
Vinnie Okada committed
646 647 648 649 650 651 652
          end

          collection do
            get :branch_from
            get :branch_to
            get :update_branches
          end
653
        end
654

Vinnie Okada's avatar
Vinnie Okada committed
655
        resources :branches, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
656 657
        resources :tags, only: [:index, :show, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex } do
          resource :release, only: [:edit, :update]
658 659
        end

Vinnie Okada's avatar
Vinnie Okada committed
660
        resources :protected_branches, only: [:index, :create, :update, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
661
        resource :variables, only: [:show, :update]
662
        resources :triggers, only: [:index, :create, :destroy]
663

664
        resources :builds, only: [:index, :show], constraints: { id: /\d+/ } do
Kamil Trzcinski's avatar
Kamil Trzcinski committed
665
          collection do
Kamil Trzcinski's avatar
Kamil Trzcinski committed
666
            post :cancel_all
Kamil Trzcinski's avatar
Kamil Trzcinski committed
667 668
          end

669 670
          member do
            get :status
671
            post :cancel
672
            post :retry
673
            post :erase
674
            get :raw
675
          end
676

677 678
          resource :artifacts, only: [] do
            get :download
679 680
            get :browse, path: 'browse(/*path)', format: false
            get :file, path: 'file/*path', format: false
681
          end
682
        end
683

Vinnie Okada's avatar
Vinnie Okada committed
684 685 686 687
        resources :hooks, only: [:index, :create, :destroy], constraints: { id: /\d+/ } do
          member do
            get :test
          end
688
        end
689

690
        resources :milestones, constraints: { id: /\d+/ } do
Vinnie Okada's avatar
Vinnie Okada committed
691 692 693 694
          member do
            put :sort_issues
            put :sort_merge_requests
          end
695
        end
696

Vinnie Okada's avatar
Vinnie Okada committed
697 698 699 700
        resources :labels, constraints: { id: /\d+/ } do
          collection do
            post :generate
          end
701 702 703 704

          member do
            post :toggle_subscription
          end
705
        end
706

707
        resources :issues, constraints: { id: /\d+/ } do
Valery Sizov's avatar
Valery Sizov committed
708
          member do
Valery Sizov's avatar
tests  
Valery Sizov committed
709
            post :toggle_subscription
710 711
            get :referenced_merge_requests
            get :related_branches
Valery Sizov's avatar
Valery Sizov committed
712
          end
Vinnie Okada's avatar
Vinnie Okada committed
713 714 715
          collection do
            post  :bulk_update
          end
716
        end
Robert Speicher's avatar
Robert Speicher committed
717

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

Vinnie Okada's avatar
Vinnie Okada committed
722 723 724 725 726
            # Used for import team
            # from another project
            get :import
            post :apply_import
          end
727 728 729 730

          member do
            post :resend_invite
          end
731
        end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
732

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

Vinnie Okada's avatar
Vinnie Okada committed
735 736 737 738
        resources :notes, only: [:index, :create, :destroy, :update], constraints: { id: /\d+/ } do
          member do
            delete :delete_attachment
          end
Valery Sizov's avatar
Valery Sizov committed
739 740 741 742

          collection do
            post :award_toggle
          end
743
        end
744 745 746

        resources :uploads, only: [:create] do
          collection do
747
            get ":secret/:filename", action: :show, as: :show, constraints: { filename: /[^\/]+/ }
748
          end
749
        end
750

751 752 753 754 755
        resources :runners, only: [:index, :edit, :update, :destroy, :show] do
          member do
            get :resume
            get :pause
          end
756 757 758 759

          collection do
            post :toggle_shared_runners
          end
760
        end
761 762

        resources :runner_projects, only: [:create, :destroy]
763
        resources :badges, only: [:index] do
764
          collection do
765 766 767
            scope '*ref', constraints: { ref: Gitlab::Regex.git_reference_regex } do
              get :build, constraints: { format: /svg/ }
            end
768 769
          end
        end
770
      end
771
    end
gitlabhq's avatar
gitlabhq committed
772
  end
773

774 775 776
  # Get all keys of user
  get ':username.keys' => 'profiles/keys#get_keys' , constraints: { username: /.*/ }

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