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
    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/}
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
R
randx 已提交
270
        post  :bulk_update
A
Adam Leonard 已提交
271
      end
V
VSizov 已提交
272
    end
R
Robert Speicher 已提交
273

274
    resources :team_members, except: [:index, :edit] do
D
Dmitriy Zaporozhets 已提交
275 276 277 278 279 280 281 282 283
      collection do

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

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

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

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