routes.rb 8.71 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"
9
  get 'search/autocomplete' => "search#autocomplete", as: :search_autocomplete
Valery Sizov's avatar
Valery Sizov committed
10

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

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

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

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

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

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

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

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

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

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

90
    resources :broadcast_messages, only: [:index, :create, :destroy]
91
    resource :logs, only: [:show]
92
    resource :background_jobs, controller: 'background_jobs', only: [:show]
93 94 95 96 97 98 99

    resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:index, :show] do
      member do
        put :transfer
      end
    end

100
    root to: "dashboard#index"
gitlabhq's avatar
gitlabhq committed
101 102
  end

103
  get "errors/githost"
randx's avatar
randx committed
104 105 106 107

  #
  # Profile Area
  #
108 109 110 111 112 113 114 115
  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
116

117
    scope module: :profiles do
118
      resource :account, only: [:show, :update]
119
      resource :notifications, only: [:show, :update]
120 121 122 123 124
      resource :password, only: [:new, :create, :edit, :update] do
        member do
          put :reset
        end
      end
125
      resources :keys
126 127 128 129 130
      resources :groups, only: [:index] do
        member do
          delete :leave
        end
      end
131
      resource :avatar, only: [:destroy]
132
    end
133
  end
134

135
  match "/u/:username" => "users#show", as: :user, constraints: { username: /.*/ }, via: :get
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
136 137


Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
138

randx's avatar
randx committed
139 140 141
  #
  # Dashboard Area
  #
142
  resource :dashboard, controller: "dashboard", only: [:show] do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
143 144 145 146 147 148
    member do
      get :projects
      get :issues
      get :merge_requests
    end
  end
gitlabhq's avatar
gitlabhq committed
149

randx's avatar
randx committed
150 151 152
  #
  # Groups Area
  #
153
  resources :groups, constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/}  do
randx's avatar
randx committed
154 155 156
    member do
      get :issues
      get :merge_requests
157
      get :members
randx's avatar
randx committed
158
    end
159 160

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

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

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

167 168 169
  #
  # Project Area
  #
170
  resources :projects, constraints: { id: /[a-zA-Z.0-9_\-]+\/[a-zA-Z.0-9_\-]+/ }, except: [:new, :create, :index], path: "/" do
171 172
    member do
      put :transfer
173
      post :fork
174 175
      post :archive
      post :unarchive
176
      get :autocomplete_sources
177 178
    end

179
    scope module: :projects do
180
      resources :blob,      only: [:show, :destroy], constraints: {id: /.+/}
181 182 183 184 185 186 187 188
      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: /.+/}
189
      resources :network,   only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}
190 191
      resources :graphs,    only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}

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

194
        resources :snippets, constraints: {id: /\d+/} do
195 196 197
          member do
            get "raw"
          end
198 199
        end

200
      resources :wikis, only: [:show, :edit, :destroy, :create], constraints: {id: /[a-zA-Z.0-9_\-]+/} do
201 202 203 204 205
        collection do
          get :pages
          put ':id' => 'wikis#update'
          get :git_access
        end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
206

207 208 209
        member do
          get "history"
        end
Valery Sizov's avatar
Valery Sizov committed
210
      end
211

212
      resource :wall, only: [:show], constraints: {id: /\d+/} do
213 214 215
        member do
          get 'notes'
        end
216 217
      end

218 219 220
      resource :repository, only: [:show] do
        member do
          get "stats"
221
          get "archive", constraints: { format: Gitlab::Regex.archive_formats_regex }
222
        end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
223
      end
224

225 226 227 228
      resources :services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do
        member do
          get :test
        end
229 230
      end

231
      resources :deploy_keys, constraints: {id: /\d+/} do
232 233 234 235
        member do
          put :enable
          put :disable
        end
236 237
      end

238
      resources :branches, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex } do
239
        collection do
240
          get :recent, constraints: { id: Gitlab::Regex.git_reference_regex }
241 242 243
        end
      end

244 245
      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
246

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

252 253
        member do
          # tree viewer logs
254
          get "logs_tree", constraints: { id: Gitlab::Regex.git_reference_regex }
255 256 257
          get "logs_tree/:path" => "refs#logs_tree",
            as: :logs_file,
            constraints: {
258
              id:   Gitlab::Regex.git_reference_regex,
259 260 261
              path: /.*/
            }
        end
gitlabhq's avatar
gitlabhq committed
262
      end
gitlabhq's avatar
gitlabhq committed
263

264 265 266 267 268 269 270
      resources :merge_requests, constraints: {id: /\d+/}, except: [:destroy] do
        member do
          get :diffs
          get :automerge
          get :automerge_check
          get :ci_status
        end
271

272 273 274
        collection do
          get :branch_from
          get :branch_to
275
          get :update_branches
276
        end
277
      end
278

279
      resources :hooks, only: [:index, :create, :destroy], constraints: {id: /\d+/} do
280 281 282
        member do
          get :test
        end
283
      end
284

285
      resources :team, controller: 'team_members', only: [:index]
286
      resources :milestones, except: [:destroy], constraints: {id: /\d+/}
287

288 289 290 291
      resources :labels, only: [:index] do
        collection do
          post :generate
        end
292 293
      end

294
      resources :issues, constraints: {id: /\d+/}, except: [:destroy] do
295 296 297
        collection do
          post  :bulk_update
        end
Adam Leonard's avatar
Adam Leonard committed
298
      end
Robert Speicher's avatar
Robert Speicher committed
299

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

304 305 306 307 308
          # Used for import team
          # from another project
          get :import
          post :apply_import
        end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
309 310
      end

311
      resources :notes, only: [:index, :create, :destroy, :update], constraints: {id: /\d+/} do
312
        member do
313
          delete :delete_attachment
314 315
        end

316 317 318 319
        collection do
          post :preview
        end
      end
320
    end
gitlabhq's avatar
gitlabhq committed
321
  end
322

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
323
  root to: "dashboard#show"
gitlabhq's avatar
gitlabhq committed
324
end