routes.rb 10.2 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 162
  get 'u/:username/calendar' => 'users#calendar', as: :user_calendar,
      constraints: { username: /(?:[^.]|\.(?!atom$))+/, format: /atom/ }

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

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

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

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

R
Robert Speicher 已提交
195
  resources :projects, constraints: { id: /[^\/]+/ }, only: [:new, :create]
196

197
  devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations , passwords: :passwords, sessions: :sessions, confirmations: :confirmations }
G
gitlabhq 已提交
198

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

216
    scope module: :projects do
217 218 219 220 221 222 223
      # 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'

224
      resources :blob, only: [:show, :destroy], constraints: { id: /.+/, format: false } do
S
skv 已提交
225 226
        get :diff, on: :member
      end
227

228 229
      resources :raw,       only: [:show], constraints: {id: /.+/}
      resources :tree,      only: [:show], constraints: {id: /.+/, format: /(html|js)/ }
230
      resource  :avatar,    only: [:show, :destroy]
231 232 233 234
      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: /.+/}
235
      resources :network,   only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}
236 237 238 239 240
      resources :graphs,    only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/} do
        member do
          get :commits
        end
      end
241

242 243
      get '/compare/:from...:to' => 'compare#show', :as => 'compare',
          :constraints => {from: /.+/, to: /.+/}
244

245 246
      resources :snippets, constraints: {id: /\d+/} do
        member do
247
          get 'raw'
248
        end
249
      end
250

M
Marin Jankovski 已提交
251
      resources :wikis, only: [:show, :edit, :destroy, :create], constraints: {id: /[a-zA-Z.0-9_\-\/]+/} do
252 253 254 255 256
        collection do
          get :pages
          put ':id' => 'wikis#update'
          get :git_access
        end
D
Dmitriy Zaporozhets 已提交
257

258
        member do
259
          get 'history'
260
        end
V
Valery Sizov 已提交
261
      end
V
Valery Sizov 已提交
262

263
      resource :fork, only: [:new, :create]
264
      resource :import, only: [:new, :create, :show]
265

266
      resource :repository, only: [:show, :create] do
267
        member do
268
          get 'archive', constraints: { format: Gitlab::Regex.archive_formats_regex }
269
        end
D
Dmitriy Zaporozhets 已提交
270
      end
271

272 273 274 275
      resources :services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do
        member do
          get :test
        end
D
Dmitriy Zaporozhets 已提交
276 277
      end

278
      resources :deploy_keys, constraints: {id: /\d+/} do
279 280 281 282
        member do
          put :enable
          put :disable
        end
283 284
      end

285
      resources :branches, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
286
      resources :tags, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
287
      resources :protected_branches, only: [:index, :create, :update, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
M
miks 已提交
288

289 290
      resources :refs, only: [] do
        collection do
291
          get 'switch'
292
        end
G
gitlabhq 已提交
293

294 295
        member do
          # tree viewer logs
296 297
          get 'logs_tree', constraints: { id: Gitlab::Regex.git_reference_regex }
          get 'logs_tree/:path' => 'refs#logs_tree',
298 299
            as: :logs_file,
            constraints: {
300
              id:   Gitlab::Regex.git_reference_regex,
301 302 303
              path: /.*/
            }
        end
G
gitlabhq 已提交
304
      end
G
gitlabhq 已提交
305

306 307 308
      resources :merge_requests, constraints: {id: /\d+/}, except: [:destroy] do
        member do
          get :diffs
309
          post :automerge
310 311 312
          get :automerge_check
          get :ci_status
        end
313

314 315 316
        collection do
          get :branch_from
          get :branch_to
I
Izaak Alpert 已提交
317
          get :update_branches
318
        end
319
      end
320

321
      resources :hooks, only: [:index, :create, :destroy], constraints: {id: /\d+/} do
322 323 324
        member do
          get :test
        end
325
      end
326

327
      resources :team, controller: 'team_members', only: [:index]
D
Dmitriy Zaporozhets 已提交
328 329 330
      resources :milestones, except: [:destroy], constraints: {id: /\d+/} do
        member do
          put :sort_issues
331
          put :sort_merge_requests
D
Dmitriy Zaporozhets 已提交
332 333
        end
      end
334

335
      resources :labels, constraints: {id: /\d+/} do
336 337 338
        collection do
          post :generate
        end
339 340
      end

341
      resources :issues, constraints: {id: /\d+/}, except: [:destroy] do
342 343 344
        collection do
          post  :bulk_update
        end
A
Adam Leonard 已提交
345
      end
R
Robert Speicher 已提交
346

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

351 352 353 354 355
          # Used for import team
          # from another project
          get :import
          post :apply_import
        end
D
Dmitriy Zaporozhets 已提交
356 357
      end

358
      resources :notes, only: [:index, :create, :destroy, :update], constraints: {id: /\d+/} do
359
        member do
360
          delete :delete_attachment
361
        end
362
      end
363

364
    end
G
gitlabhq 已提交
365
  end
R
Robert Speicher 已提交
366

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

369
  root to: 'dashboard#show'
G
gitlabhq 已提交
370
end