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

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

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

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

41 42 43 44 45 46 47 48
  #
  # Public namespace
  #
  namespace :public do
    resources :projects, only: [:index]
    root to: "projects#index"
  end

49 50 51
  #
  # Attachments serving
  #
52
  get 'files/:type/:id/:filename' => 'files#download', constraints: { id: /\d+/, type: /[a-z]+/, filename:  /.+/ }
53

54 55 56
  #
  # Admin Area
  #
Nihad Abbasov's avatar
Nihad Abbasov committed
57
  namespace :admin do
58
    resources :users, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do
59
      member do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
60
        put :team_update
61 62
        put :block
        put :unblock
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
63 64
      end
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
65

66 67 68
    resources :groups, constraints: { id: /[^\/]+/ } do
      member do
        put :project_update
69
        put :project_teams_update
70
        delete :remove_project
71 72
      end
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
73 74

    resources :teams, constraints: { id: /[^\/]+/ } do
75
      scope module: :teams do
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
76 77
        resources :members,   only: [:edit, :update, :destroy, :new, :create]
        resources :projects,  only: [:edit, :update, :destroy, :new, :create], constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }
78
      end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
79
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
80

81
    resources :hooks, only: [:index, :create, :destroy] do
Valeriy Sizov's avatar
Valeriy Sizov committed
82 83
      get :test
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
84

85
    resource :logs, only: [:show]
86
    resource :resque, controller: 'resque', only: [:show]
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
87

88
    resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:index, :show] do
89
      scope module: :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
90 91 92 93
        resources :members, only: [:edit, :update, :destroy]
      end
    end

94
    root to: "dashboard#index"
gitlabhq's avatar
gitlabhq committed
95 96
  end

97
  get "errors/githost"
randx's avatar
randx committed
98 99 100 101

  #
  # Profile Area
  #
102 103 104 105 106 107 108 109 110 111 112
  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
113 114

    resource :notifications
115
  end
116

117
  resources :keys
118
  match "/u/:username" => "users#show", as: :user, constraints: { username: /.*/ }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
119 120


Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
121

randx's avatar
randx committed
122 123 124
  #
  # Dashboard Area
  #
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
125 126 127 128 129 130 131
  resource :dashboard, controller: "dashboard" do
    member do
      get :projects
      get :issues
      get :merge_requests
    end
  end
gitlabhq's avatar
gitlabhq committed
132

randx's avatar
randx committed
133 134 135
  #
  # Groups Area
  #
136
  resources :groups, constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/}  do
randx's avatar
randx committed
137 138 139 140 141
    member do
      get :issues
      get :merge_requests
      get :search
      get :people
142
      post :team_members
randx's avatar
randx committed
143 144 145
    end
  end

Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
146 147 148
  #
  # Teams Area
  #
149
  resources :teams, constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/} do
150 151 152 153
    member do
      get :issues
      get :merge_requests
    end
154
    scope module: :teams do
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
155 156
      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_\-\/]+/ }
157
    end
158 159
  end

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

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

164 165 166
  #
  # Project Area
  #
Sato Hiroyuki's avatar
Sato Hiroyuki committed
167
  resources :projects, constraints: { id: /(?:[a-zA-Z.0-9_\-]+\/)?[a-zA-Z.0-9_\-]+/ }, except: [:new, :create, :index], path: "/" do
168 169
    member do
      put :transfer
170
      post :fork
171
      get :autocomplete_sources
172 173
    end

174
    resources :blob,    only: [:show], constraints: {id: /.+/}
175
    resources :raw,    only: [:show], constraints: {id: /.+/}
176 177
    resources :tree,    only: [:show], constraints: {id: /.+/, format: /(html|js)/ }
    resources :edit_tree,    only: [:show, :update], constraints: {id: /.+/}, path: 'edit'
178
    resources :commit,  only: [:show], constraints: {id: /[[:alnum:]]{6,40}/}
Sato Hiroyuki's avatar
Sato Hiroyuki committed
179
    resources :commits, only: [:show], constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/}
180 181
    resources :compare, only: [:index, :create]
    resources :blame,   only: [:show], constraints: {id: /.+/}
Sato Hiroyuki's avatar
Sato Hiroyuki committed
182
    resources :graph,   only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}
183 184 185
    match "/compare/:from...:to" => "compare#show", as: "compare",
                    :via => [:get, :post], constraints: {from: /.+/, to: /.+/}

186
    resources :wikis, only: [:show, :edit, :destroy, :create] do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
187 188
      collection do
        get :pages
189 190
        put ':id' => 'wikis#update'
        get :git_access
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
191 192
      end

Valery Sizov's avatar
Valery Sizov committed
193
      member do
194
        get "history"
Valery Sizov's avatar
Valery Sizov committed
195 196
      end
    end
197

198 199 200 201 202 203
    resource :wall, only: [:show] do
      member do
        get 'notes'
      end
    end

204 205
    resource :repository do
      member do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
206 207
        get "branches"
        get "tags"
randx's avatar
randx committed
208
        get "stats"
209
        get "archive"
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
210 211
      end
    end
212

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

miks's avatar
miks committed
219
    resources :deploy_keys
220
    resources :protected_branches, only: [:index, :create, :destroy]
miks's avatar
miks committed
221

222
    resources :refs, only: [] do
223
      collection do
gitlabhq's avatar
gitlabhq committed
224 225 226
        get "switch"
      end

227
      member do
228 229
        # tree viewer logs
        get "logs_tree", constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }
230
        get "logs_tree/:path" => "refs#logs_tree",
231 232 233 234
          as: :logs_file,
          constraints: {
            id:   /[a-zA-Z.0-9\/_\-]+/,
            path: /.*/
235
          }
gitlabhq's avatar
gitlabhq committed
236
      end
gitlabhq's avatar
gitlabhq committed
237
    end
gitlabhq's avatar
gitlabhq committed
238

239
    resources :merge_requests, constraints: {id: /\d+/}, except: [:destroy] do
240
      member do
241
        get :diffs
randx's avatar
randx committed
242
        get :automerge
Valery Sizov's avatar
Valery Sizov committed
243
        get :automerge_check
244
        get :ci_status
245
      end
246

247
      collection do
248 249 250
        get :branch_from
        get :branch_to
      end
251
    end
252 253 254

    resources :snippets do
      member do
255 256 257 258
        get "raw"
      end
    end

259
    resources :hooks, only: [:index, :create, :destroy] do
260
      member do
261 262 263
        get :test
      end
    end
264 265


266
    resources :team, controller: 'team_members', only: [:index]
267
    resources :milestones, except: [:destroy]
268
    resources :labels, only: [:index]
269
    resources :issues, except: [:destroy] do
VSizov's avatar
VSizov committed
270
      collection do
randx's avatar
randx committed
271
        post  :bulk_update
Adam Leonard's avatar
Adam Leonard committed
272
      end
VSizov's avatar
VSizov committed
273
    end
Robert Speicher's avatar
Robert Speicher committed
274

275
    resources :team_members, except: [:index, :edit] do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
276 277 278 279 280 281 282 283 284
      collection do

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

285 286 287
    scope module: :projects do
      resources :teams, only: [] do
        collection do
288
          get :available
289 290 291 292 293 294 295 296
          post :assign
        end
        member do
          delete :resign
        end
      end
    end

297
    resources :notes, only: [:index, :create, :destroy] do
298 299 300 301
      collection do
        post :preview
      end
    end
gitlabhq's avatar
gitlabhq committed
302
  end
303

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
304
  root to: "dashboard#show"
gitlabhq's avatar
gitlabhq committed
305
end