routes.rb 8.33 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
  get 'help'                => 'help#index'
  get 'help/api'            => 'help#api'
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
32
  get 'help/api/:category'  => 'help#api', as: 'help_api_file'
Riyad Preukschas's avatar
Riyad Preukschas committed
33 34
  get 'help/markdown'       => 'help#markdown'
  get 'help/permissions'    => 'help#permissions'
35
  get 'help/public_access'  => 'help#public_access'
Riyad Preukschas's avatar
Riyad Preukschas committed
36 37 38 39 40
  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'
41
  get 'help/shortcuts'
42
  get 'help/security'
43

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

54 55 56 57 58 59 60 61
  #
  # Public namespace
  #
  namespace :public do
    resources :projects, only: [:index]
    root to: "projects#index"
  end

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

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

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

85
    resources :hooks, only: [:index, :create, :destroy] do
Valeriy Sizov's avatar
Valeriy Sizov committed
86 87
      get :test
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
88

89
    resource :logs, only: [:show]
90
    resource :background_jobs, controller: 'background_jobs', only: [:show]
91
    resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:index, :show]
92
    root to: "dashboard#index"
gitlabhq's avatar
gitlabhq committed
93 94
  end

95
  get "errors/githost"
randx's avatar
randx committed
96 97 98 99

  #
  # Profile Area
  #
100 101 102 103 104 105 106 107
  resource :profile, only: [:show, :update] do
    member do
      get :history
      get :design

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

109
    scope module: :profiles do
110
      resource :account, only: [:show, :update]
111
      resource :notifications, only: [:show, :update]
112 113 114 115 116
      resource :password, only: [:new, :create, :edit, :update] do
        member do
          put :reset
        end
      end
117
      resources :keys
118 119 120 121 122
      resources :groups, only: [:index] do
        member do
          delete :leave
        end
      end
123
    end
124
  end
125

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


Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
129

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

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

    resources :users_groups, only: [:create, :update, :destroy]
randx's avatar
randx committed
152 153
  end

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

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

158 159 160
  #
  # Project Area
  #
161
  resources :projects, constraints: { id: /[a-zA-Z.0-9_\-]+\/[a-zA-Z.0-9_\-]+/ }, except: [:new, :create, :index], path: "/" do
162 163
    member do
      put :transfer
164
      post :fork
165
      get :autocomplete_sources
166 167
    end

168
    scope module: :projects do
169 170 171 172 173 174 175 176 177
      resources :blob,      only: [:show], constraints: {id: /.+/}
      resources :raw,       only: [:show], constraints: {id: /.+/}
      resources :tree,      only: [:show], constraints: {id: /.+/, format: /(html|js)/ }
      resources :edit_tree, only: [:show, :update], constraints: {id: /.+/}, path: 'edit'
      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: /.+/}
178
      resources :network,   only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}
179 180
      resources :graphs,    only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}

181 182
      match "/compare/:from...:to" => "compare#show", as: "compare", via: [:get, :post], constraints: {from: /.+/, to: /.+/}

183
        resources :snippets, constraints: {id: /\d+/} do
184 185 186
          member do
            get "raw"
          end
187 188
        end

189
      resources :wikis, only: [:show, :edit, :destroy, :create], constraints: {id: /[a-zA-Z.0-9_\-]+/} do
190 191 192 193 194
        collection do
          get :pages
          put ':id' => 'wikis#update'
          get :git_access
        end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
195

196 197 198
        member do
          get "history"
        end
Valery Sizov's avatar
Valery Sizov committed
199
      end
200

201
      resource :wall, only: [:show], constraints: {id: /\d+/} do
202 203 204
        member do
          get 'notes'
        end
205 206
      end

207 208 209 210 211
      resource :repository, only: [:show] do
        member do
          get "stats"
          get "archive"
        end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
212
      end
213

214 215 216 217
      resources :services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do
        member do
          get :test
        end
218 219
      end

220
      resources :deploy_keys, constraints: {id: /\d+/} do
221 222 223 224
        member do
          put :enable
          put :disable
        end
225 226
      end

227
      resources :branches, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex } do
228
        collection do
229
          get :recent, constraints: { id: Gitlab::Regex.git_reference_regex }
230 231 232
        end
      end

233 234
      resources :tags, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
      resources :protected_branches, only: [:index, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
miks's avatar
miks committed
235

236 237 238 239
      resources :refs, only: [] do
        collection do
          get "switch"
        end
gitlabhq's avatar
gitlabhq committed
240

241 242
        member do
          # tree viewer logs
243
          get "logs_tree", constraints: { id: Gitlab::Regex.git_reference_regex }
244 245 246
          get "logs_tree/:path" => "refs#logs_tree",
            as: :logs_file,
            constraints: {
247
              id:   Gitlab::Regex.git_reference_regex,
248 249 250
              path: /.*/
            }
        end
gitlabhq's avatar
gitlabhq committed
251
      end
gitlabhq's avatar
gitlabhq committed
252

253 254 255 256 257 258 259
      resources :merge_requests, constraints: {id: /\d+/}, except: [:destroy] do
        member do
          get :diffs
          get :automerge
          get :automerge_check
          get :ci_status
        end
260

261 262 263
        collection do
          get :branch_from
          get :branch_to
264
          get :update_branches
265
        end
266
      end
267

268
      resources :hooks, only: [:index, :create, :destroy], constraints: {id: /\d+/} do
269 270 271
        member do
          get :test
        end
272
      end
273

274
      resources :team, controller: 'team_members', only: [:index]
275
      resources :milestones, except: [:destroy], constraints: {id: /\d+/}
276

277 278 279 280
      resources :labels, only: [:index] do
        collection do
          post :generate
        end
281 282
      end

283
      resources :issues, constraints: {id: /\d+/}, except: [:destroy] do
284 285 286
        collection do
          post  :bulk_update
        end
Adam Leonard's avatar
Adam Leonard committed
287
      end
Robert Speicher's avatar
Robert Speicher committed
288

289
      resources :team_members, except: [:index, :edit], constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ } do
290
        collection do
291
          delete :leave
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
292

293 294 295 296 297
          # Used for import team
          # from another project
          get :import
          post :apply_import
        end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
298 299
      end

300
      resources :notes, only: [:index, :create, :destroy, :update], constraints: {id: /\d+/} do
301
        member do
302
          delete :delete_attachment
303 304
        end

305 306 307 308
        collection do
          post :preview
        end
      end
309
    end
gitlabhq's avatar
gitlabhq committed
310
  end
311

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
312
  root to: "dashboard#show"
gitlabhq's avatar
gitlabhq committed
313
end