routes.rb 7.4 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 89 90 91 92

    resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, except: [:new, :create] do
      member do
        get :team
        put :team_update
      end
93
      scope module: :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do
A
Andrey Kumanyaev 已提交
94 95 96 97
        resources :members, only: [:edit, :update, :destroy]
      end
    end

R
Robert Speicher 已提交
98
    root to: "dashboard#index"
G
gitlabhq 已提交
99 100
  end

101
  get "errors/githost"
R
randx 已提交
102 103 104 105

  #
  # Profile Area
  #
106 107 108 109 110 111 112 113 114 115 116 117
  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
  end
R
Robert Speicher 已提交
118

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


D
Dmitriy Zaporozhets 已提交
123

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

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

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

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

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

166 167 168
  #
  # Project Area
  #
S
Sato Hiroyuki 已提交
169
  resources :projects, constraints: { id: /(?:[a-zA-Z.0-9_\-]+\/)?[a-zA-Z.0-9_\-]+/ }, except: [:new, :create, :index], path: "/" do
170 171 172 173
    member do
      put :transfer
    end

174
    resources :blob,    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/}
D
Dmitriy Zaporozhets 已提交
182 183 184
    match "/compare/:from...:to" => "compare#show", as: "compare",
                    :via => [:get, :post], constraints: {from: /.+/, to: /.+/}

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

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

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

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

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

M
miks 已提交
218
    resources :deploy_keys
R
Robert Speicher 已提交
219
    resources :protected_branches, only: [:index, :create, :destroy]
M
miks 已提交
220

221
    resources :refs, only: [] do
222
      collection do
G
gitlabhq 已提交
223 224 225
        get "switch"
      end

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

D
Dmitriy Zaporozhets 已提交
238
    resources :merge_requests, constraints: {id: /\d+/}, except: [:destroy] do
239
      member do
240
        get :diffs
R
randx 已提交
241
        get :automerge
V
Valery Sizov 已提交
242
        get :automerge_check
243
        get :ci_status
244
      end
245

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

    resources :snippets do
      member do
R
randx 已提交
254 255 256 257
        get "raw"
      end
    end

R
Robert Speicher 已提交
258
    resources :hooks, only: [:index, :create, :destroy] do
259
      member do
260 261 262
        get :test
      end
    end
263 264


R
Robert Speicher 已提交
265
    resources :team, controller: 'team_members', only: [:index]
D
Dmitriy Zaporozhets 已提交
266
    resources :milestones, except: [:destroy]
R
Robert Speicher 已提交
267
    resources :labels, only: [:index]
D
Dmitriy Zaporozhets 已提交
268
    resources :issues, except: [:destroy] do
V
VSizov 已提交
269
      collection do
270
        post  :sort
R
randx 已提交
271
        post  :bulk_update
272
        get   :search
A
Adam Leonard 已提交
273
      end
V
VSizov 已提交
274
    end
R
Robert Speicher 已提交
275

D
Dmitriy Zaporozhets 已提交
276 277 278 279 280 281 282 283 284 285
    resources :team_members do
      collection do

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

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

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

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