routes.rb 7.5 KB
Newer Older
D
sidekiq  
Dmitriy Zaporozhets 已提交
1 2
require 'sidekiq/web'

G
gitlabhq 已提交
3
Gitlab::Application.routes.draw do
4 5 6
  #
  # Search
  #
7
  get 'search' => "search#show"
V
Valery Sizov 已提交
8

9 10
  # API
  require 'api'
F
Felix Gilcher 已提交
11
  Gitlab::API.logger Rails.logger
12 13
  mount Gitlab::API => '/api'

D
sidekiq  
Dmitriy Zaporozhets 已提交
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
D
sidekiq  
Dmitriy Zaporozhets 已提交
17
  end
A
Ariejan de Vroom 已提交
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
A
Andrey Kumanyaev 已提交
25
  }), at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) }
26

27 28 29
  #
  # Help
  #
R
Riyad Preukschas 已提交
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'
R
Riyad Preukschas 已提交
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
  #
N
Nihad Abbasov 已提交
57
  namespace :admin do
58
    resources :users, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do
59
      member do
D
Dmitriy Zaporozhets 已提交
60
        put :team_update
61 62
        put :block
        put :unblock
D
Dmitriy Zaporozhets 已提交
63 64
      end
    end
A
Andrey Kumanyaev 已提交
65

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

    resources :teams, constraints: { id: /[^\/]+/ } do
75
      scope module: :teams do
A
Andrey Kumanyaev 已提交
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
A
Andrey Kumanyaev 已提交
79
    end
A
Andrey Kumanyaev 已提交
80

R
Robert Speicher 已提交
81
    resources :hooks, only: [:index, :create, :destroy] do
V
Valeriy Sizov 已提交
82 83
      get :test
    end
A
Andrey Kumanyaev 已提交
84

85
    resource :logs, only: [:show]
R
Robert Speicher 已提交
86
    resource :resque, controller: 'resque', only: [:show]
A
Andrey Kumanyaev 已提交
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
A
Andrey Kumanyaev 已提交
90 91 92 93
        resources :members, only: [:edit, :update, :destroy]
      end
    end

R
Robert Speicher 已提交
94
    root to: "dashboard#index"
G
gitlabhq 已提交
95 96
  end

97
  get "errors/githost"
R
randx 已提交
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
D
Dmitriy Zaporozhets 已提交
113 114

    resource :notifications
115
  end
R
Robert Speicher 已提交
116

117
  resources :keys
118
  match "/u/:username" => "users#show", as: :user, constraints: { username: /.*/ }
D
Dmitriy Zaporozhets 已提交
119 120


D
Dmitriy Zaporozhets 已提交
121

R
randx 已提交
122 123 124
  #
  # Dashboard Area
  #
D
Dmitriy Zaporozhets 已提交
125 126 127 128 129 130 131
  resource :dashboard, controller: "dashboard" do
    member do
      get :projects
      get :issues
      get :merge_requests
    end
  end
G
gitlabhq 已提交
132

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

A
Andrey Kumanyaev 已提交
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
A
Andrey Kumanyaev 已提交
154
    scope module: :teams do
A
Andrey Kumanyaev 已提交
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_\-\/]+/ }
A
Andrey Kumanyaev 已提交
157
    end
158 159
  end

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

M
Marin Jankovski 已提交
162
  devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations }
G
gitlabhq 已提交
163

164 165 166
  #
  # Project Area
  #
S
Sato Hiroyuki 已提交
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 172
    end

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

R
Robert Speicher 已提交
184
    resources :wikis, only: [:show, :edit, :destroy, :create] do
D
Dmitriy Zaporozhets 已提交
185 186
      collection do
        get :pages
187 188
        put ':id' => 'wikis#update'
        get :git_access
D
Dmitriy Zaporozhets 已提交
189 190
      end

V
Valery Sizov 已提交
191
      member do
192
        get "history"
V
Valery Sizov 已提交
193 194
      end
    end
V
Valery Sizov 已提交
195

D
Dmitriy Zaporozhets 已提交
196 197 198 199 200 201
    resource :wall, only: [:show] do
      member do
        get 'notes'
      end
    end

202 203
    resource :repository do
      member do
D
Dmitriy Zaporozhets 已提交
204 205
        get "branches"
        get "tags"
R
randx 已提交
206
        get "stats"
207
        get "archive"
D
Dmitriy Zaporozhets 已提交
208 209
      end
    end
210

D
Dmitriy Zaporozhets 已提交
211 212 213 214 215 216
    resources :services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do
      member do
        get :test
      end
    end

217 218 219 220 221 222 223
    resources :deploy_keys do
      member do
        put :enable
        put :disable
      end
    end

R
Robert Speicher 已提交
224
    resources :protected_branches, only: [:index, :create, :destroy]
M
miks 已提交
225

226
    resources :refs, only: [] do
227
      collection do
G
gitlabhq 已提交
228 229 230
        get "switch"
      end

231
      member do
232 233
        # tree viewer logs
        get "logs_tree", constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }
R
randx 已提交
234
        get "logs_tree/:path" => "refs#logs_tree",
R
Robert Speicher 已提交
235 236 237 238
          as: :logs_file,
          constraints: {
            id:   /[a-zA-Z.0-9\/_\-]+/,
            path: /.*/
R
randx 已提交
239
          }
G
gitlabhq 已提交
240
      end
G
gitlabhq 已提交
241
    end
G
gitlabhq 已提交
242

D
Dmitriy Zaporozhets 已提交
243
    resources :merge_requests, constraints: {id: /\d+/}, except: [:destroy] do
244
      member do
245
        get :diffs
R
randx 已提交
246
        get :automerge
V
Valery Sizov 已提交
247
        get :automerge_check
248
        get :ci_status
249
      end
250

251
      collection do
252 253 254
        get :branch_from
        get :branch_to
      end
255
    end
256 257 258

    resources :snippets do
      member do
R
randx 已提交
259 260 261 262
        get "raw"
      end
    end

R
Robert Speicher 已提交
263
    resources :hooks, only: [:index, :create, :destroy] do
264
      member do
265 266 267
        get :test
      end
    end
268 269


R
Robert Speicher 已提交
270
    resources :team, controller: 'team_members', only: [:index]
D
Dmitriy Zaporozhets 已提交
271
    resources :milestones, except: [:destroy]
R
Robert Speicher 已提交
272
    resources :labels, only: [:index]
D
Dmitriy Zaporozhets 已提交
273
    resources :issues, except: [:destroy] do
V
VSizov 已提交
274
      collection do
R
randx 已提交
275
        post  :bulk_update
A
Adam Leonard 已提交
276
      end
V
VSizov 已提交
277
    end
R
Robert Speicher 已提交
278

279
    resources :team_members, except: [:index, :edit] do
D
Dmitriy Zaporozhets 已提交
280 281 282 283 284 285 286 287 288
      collection do

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

289 290 291
    scope module: :projects do
      resources :teams, only: [] do
        collection do
292
          get :available
293 294 295 296 297 298 299 300
          post :assign
        end
        member do
          delete :resign
        end
      end
    end

R
Robert Speicher 已提交
301
    resources :notes, only: [:index, :create, :destroy] do
302 303 304 305
      collection do
        post :preview
      end
    end
G
gitlabhq 已提交
306
  end
R
Robert Speicher 已提交
307

D
Dmitriy Zaporozhets 已提交
308
  root to: "dashboard#show"
G
gitlabhq 已提交
309
end