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

gitlabhq's avatar
gitlabhq committed
4
Gitlab::Application.routes.draw do
5 6 7
  #
  # Search
  #
8
  get 'search' => "search#show"
Valery Sizov's avatar
Valery Sizov committed
9

10
  # API
11 12
  API::API.logger Rails.logger
  mount API::API => '/api'
13

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
14 15
  constraint = lambda { |request| request.env["warden"].authenticate? and request.env['warden'].user.admin? }
  constraints constraint do
16
    mount Sidekiq::Web, at: "/admin/sidekiq", as: :sidekiq
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
17
  end
Ariejan de Vroom's avatar
Ariejan de Vroom committed
18

19 20
  # Enable Grack support
  mount Grack::Bundle.new({
21
    git_path:     Gitlab.config.git.bin_path,
22 23 24
    project_root: Gitlab.config.gitlab_shell.repos_path,
    upload_pack:  Gitlab.config.gitlab_shell.upload_pack,
    receive_pack: Gitlab.config.gitlab_shell.receive_pack
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
25
  }), at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) }
26

27 28 29
  #
  # Help
  #
Riyad Preukschas's avatar
Riyad Preukschas committed
30 31 32 33
  get 'help'                => 'help#index'
  get 'help/api'            => 'help#api'
  get 'help/markdown'       => 'help#markdown'
  get 'help/permissions'    => 'help#permissions'
34
  get 'help/public_access'  => 'help#public_access'
Riyad Preukschas's avatar
Riyad Preukschas committed
35 36 37 38 39
  get 'help/raketasks'      => 'help#raketasks'
  get 'help/ssh'            => 'help#ssh'
  get 'help/system_hooks'   => 'help#system_hooks'
  get 'help/web_hooks'      => 'help#web_hooks'
  get 'help/workflow'       => 'help#workflow'
40

Andrew8xx8's avatar
Andrew8xx8 committed
41 42 43 44 45 46 47 48
  #
  # Global snippets
  #
  resources :snippets do
    member do
      get "raw"
    end
  end
Andrew8xx8's avatar
Andrew8xx8 committed
49
  get "/s/:username" => "snippets#user_index", as: :user_snippets, constraints: { username: /.*/ }
Andrew8xx8's avatar
Andrew8xx8 committed
50

51 52 53 54 55 56 57 58
  #
  # Public namespace
  #
  namespace :public do
    resources :projects, only: [:index]
    root to: "projects#index"
  end

59 60 61
  #
  # Attachments serving
  #
62
  get 'files/:type/:id/:filename' => 'files#download', constraints: { id: /\d+/, type: /[a-z]+/, filename:  /.+/ }
63

64 65 66
  #
  # Admin Area
  #
Nihad Abbasov's avatar
Nihad Abbasov committed
67
  namespace :admin do
68
    resources :users, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do
69
      member do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
70
        put :team_update
71 72
        put :block
        put :unblock
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
73 74
      end
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
75

76 77 78
    resources :groups, constraints: { id: /[^\/]+/ } do
      member do
        put :project_update
79
        put :project_teams_update
80
        delete :remove_project
81 82
      end
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
83 84

    resources :teams, constraints: { id: /[^\/]+/ } do
85
      scope module: :teams do
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
86 87
        resources :members,   only: [:edit, :update, :destroy, :new, :create]
        resources :projects,  only: [:edit, :update, :destroy, :new, :create], constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }
88
      end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
89
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
90

91
    resources :hooks, only: [:index, :create, :destroy] do
Valeriy Sizov's avatar
Valeriy Sizov committed
92 93
      get :test
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
94

95
    resource :logs, only: [:show]
96
    resource :background_jobs, controller: 'background_jobs', only: [:show]
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
97

98
    resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:index, :show] do
99
      scope module: :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
100 101 102 103
        resources :members, only: [:edit, :update, :destroy]
      end
    end

104
    root to: "dashboard#index"
gitlabhq's avatar
gitlabhq committed
105 106
  end

107
  get "errors/githost"
randx's avatar
randx committed
108 109 110 111

  #
  # Profile Area
  #
112 113 114 115 116 117 118 119 120 121 122
  resource :profile, only: [:show, :update] do
    member do
      get :account
      get :history
      get :token
      get :design

      put :update_password
      put :reset_private_token
      put :update_username
    end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
123 124

    resource :notifications
125
  end
126

127
  resources :keys
128
  match "/u/:username" => "users#show", as: :user, constraints: { username: /.*/ }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
129 130


Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
131

randx's avatar
randx committed
132 133 134
  #
  # Dashboard Area
  #
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
135 136 137 138 139 140 141
  resource :dashboard, controller: "dashboard" do
    member do
      get :projects
      get :issues
      get :merge_requests
    end
  end
gitlabhq's avatar
gitlabhq committed
142

randx's avatar
randx committed
143 144 145
  #
  # Groups Area
  #
146
  resources :groups, constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/}  do
randx's avatar
randx committed
147 148 149 150 151
    member do
      get :issues
      get :merge_requests
      get :search
      get :people
152
      post :team_members
randx's avatar
randx committed
153 154 155
    end
  end

Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
156 157 158
  #
  # Teams Area
  #
159
  resources :teams, constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/} do
160 161 162 163
    member do
      get :issues
      get :merge_requests
    end
164
    scope module: :teams do
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
165 166
      resources :members,   only: [:index, :new, :create, :edit, :update, :destroy]
      resources :projects,  only: [:index, :new, :create, :edit, :update, :destroy], constraints: { id: /[a-zA-Z.0-9_\-\/]+/ }
167
    end
168 169
  end

170
  resources :projects, constraints: { id: /[^\/]+/ }, only: [:new, :create]
171

Marin Jankovski's avatar
Marin Jankovski committed
172
  devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations }
gitlabhq's avatar
gitlabhq committed
173

174 175 176
  #
  # Project Area
  #
Sato Hiroyuki's avatar
Sato Hiroyuki committed
177
  resources :projects, constraints: { id: /(?:[a-zA-Z.0-9_\-]+\/)?[a-zA-Z.0-9_\-]+/ }, except: [:new, :create, :index], path: "/" do
178 179
    member do
      put :transfer
180
      post :fork
181
      get :autocomplete_sources
182 183
    end

184
    resources :blob,    only: [:show], constraints: {id: /.+/}
185
    resources :raw,    only: [:show], constraints: {id: /.+/}
186 187
    resources :tree,    only: [:show], constraints: {id: /.+/, format: /(html|js)/ }
    resources :edit_tree,    only: [:show, :update], constraints: {id: /.+/}, path: 'edit'
188
    resources :commit,  only: [:show], constraints: {id: /[[:alnum:]]{6,40}/}
Sato Hiroyuki's avatar
Sato Hiroyuki committed
189
    resources :commits, only: [:show], constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/}
190 191
    resources :compare, only: [:index, :create]
    resources :blame,   only: [:show], constraints: {id: /.+/}
Sato Hiroyuki's avatar
Sato Hiroyuki committed
192
    resources :graph,   only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}
193
    resources :stat_graph, only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}
194
    match "/compare/:from...:to" => "compare#show", as: "compare", via: [:get, :post], constraints: {from: /.+/, to: /.+/}
195

196 197 198 199 200 201 202 203
    scope module: :projects do
      resources :snippets do
        member do
          get "raw"
        end
      end
    end

204
    resources :wikis, only: [:show, :edit, :destroy, :create] do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
205 206
      collection do
        get :pages
207 208
        put ':id' => 'wikis#update'
        get :git_access
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
209 210
      end

Valery Sizov's avatar
Valery Sizov committed
211
      member do
212
        get "history"
Valery Sizov's avatar
Valery Sizov committed
213 214
      end
    end
215

216 217 218 219 220 221
    resource :wall, only: [:show] do
      member do
        get 'notes'
      end
    end

222 223
    resource :repository do
      member do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
224 225
        get "branches"
        get "tags"
randx's avatar
randx committed
226
        get "stats"
227
        get "archive"
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
228 229
      end
    end
230

231 232 233 234 235 236
    resources :services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do
      member do
        get :test
      end
    end

237 238 239 240 241 242 243
    resources :deploy_keys do
      member do
        put :enable
        put :disable
      end
    end

244
    resources :protected_branches, only: [:index, :create, :destroy]
miks's avatar
miks committed
245

246
    resources :refs, only: [] do
247
      collection do
gitlabhq's avatar
gitlabhq committed
248 249 250
        get "switch"
      end

251
      member do
252 253
        # tree viewer logs
        get "logs_tree", constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }
254
        get "logs_tree/:path" => "refs#logs_tree",
255 256 257 258
          as: :logs_file,
          constraints: {
            id:   /[a-zA-Z.0-9\/_\-]+/,
            path: /.*/
259
          }
gitlabhq's avatar
gitlabhq committed
260
      end
gitlabhq's avatar
gitlabhq committed
261
    end
gitlabhq's avatar
gitlabhq committed
262

263
    resources :merge_requests, constraints: {id: /\d+/}, except: [:destroy] do
264
      member do
265
        get :diffs
randx's avatar
randx committed
266
        get :automerge
Valery Sizov's avatar
Valery Sizov committed
267
        get :automerge_check
268
        get :ci_status
269
      end
270

271
      collection do
272 273 274
        get :branch_from
        get :branch_to
      end
275
    end
276

277
    resources :hooks, only: [:index, :create, :destroy] do
278
      member do
279 280 281
        get :test
      end
    end
282

283
    resources :team, controller: 'team_members', only: [:index]
284
    resources :milestones, except: [:destroy]
285 286 287 288 289 290 291

    resources :labels, only: [:index] do
      collection do
        post :generate
      end
    end

292
    resources :issues, except: [:destroy] do
VSizov's avatar
VSizov committed
293
      collection do
randx's avatar
randx committed
294
        post  :bulk_update
Adam Leonard's avatar
Adam Leonard committed
295
      end
VSizov's avatar
VSizov committed
296
    end
Robert Speicher's avatar
Robert Speicher committed
297

298
    resources :team_members, except: [:index, :edit] do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
299 300 301 302 303 304 305 306 307
      collection do

        # Used for import team
        # from another project
        get :import
        post :apply_import
      end
    end

308 309 310
    scope module: :projects do
      resources :teams, only: [] do
        collection do
311
          get :available
312 313 314 315 316 317 318 319
          post :assign
        end
        member do
          delete :resign
        end
      end
    end

320
    resources :notes, only: [:index, :create, :destroy] do
321 322 323 324
      collection do
        post :preview
      end
    end
gitlabhq's avatar
gitlabhq committed
325
  end
326

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
327
  root to: "dashboard#show"
gitlabhq's avatar
gitlabhq committed
328
end