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

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

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

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
  get 'help'                => 'help#index'
  get 'help/api'            => 'help#api'
D
Dmitriy Zaporozhets 已提交
32
  get 'help/api/:category'  => 'help#api', as: 'help_api_file'
R
Riyad Preukschas 已提交
33 34
  get 'help/markdown'       => 'help#markdown'
  get 'help/permissions'    => 'help#permissions'
35
  get 'help/public_access'  => 'help#public_access'
R
Riyad Preukschas 已提交
36 37 38 39 40
  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'
D
Dmitriy Zaporozhets 已提交
41
  get 'help/shortcuts'
42

A
Andrew8xx8 已提交
43 44 45 46 47 48 49 50
  #
  # Global snippets
  #
  resources :snippets do
    member do
      get "raw"
    end
  end
A
Andrew8xx8 已提交
51
  get "/s/:username" => "snippets#user_index", as: :user_snippets, constraints: { username: /.*/ }
A
Andrew8xx8 已提交
52

53 54 55 56 57
  #
  # Public namespace
  #
  namespace :public do
    resources :projects, only: [:index]
58 59
    resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:show]

60 61 62
    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
  #
N
Nihad Abbasov 已提交
71
  namespace :admin do
72
    resources :users, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do
73
      member do
D
Dmitriy Zaporozhets 已提交
74
        put :team_update
75 76
        put :block
        put :unblock
D
Dmitriy Zaporozhets 已提交
77 78
      end
    end
A
Andrey Kumanyaev 已提交
79

80 81
    resources :groups, constraints: { id: /[^\/]+/ } do
      member do
A
Andrey Kumanyaev 已提交
82
        put :project_teams_update
83
      end
A
Andrey Kumanyaev 已提交
84
    end
A
Andrey Kumanyaev 已提交
85

R
Robert Speicher 已提交
86
    resources :hooks, only: [:index, :create, :destroy] do
V
Valeriy Sizov 已提交
87 88
      get :test
    end
A
Andrey Kumanyaev 已提交
89

90
    resource :logs, only: [:show]
91
    resource :background_jobs, controller: 'background_jobs', only: [:show]
92
    resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:index, :show]
R
Robert Speicher 已提交
93
    root to: "dashboard#index"
G
gitlabhq 已提交
94 95
  end

96
  get "errors/githost"
R
randx 已提交
97 98 99 100

  #
  # Profile Area
  #
101 102 103 104 105 106 107 108 109 110 111
  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 已提交
112

113 114 115 116
    scope module: :profiles do
      resource :notifications, only: [:show, :update]
      resource :password, only: [:new, :create]
      resources :keys
117 118 119 120 121
      resources :groups, only: [:index] do
        member do
          delete :leave
        end
      end
122
    end
123
  end
R
Robert Speicher 已提交
124

125
  match "/u/:username" => "users#show", as: :user, constraints: { username: /.*/ }
D
Dmitriy Zaporozhets 已提交
126 127


D
Dmitriy Zaporozhets 已提交
128

R
randx 已提交
129 130 131
  #
  # Dashboard Area
  #
132
  resource :dashboard, controller: "dashboard", only: [:show] do
D
Dmitriy Zaporozhets 已提交
133 134 135 136 137 138
    member do
      get :projects
      get :issues
      get :merge_requests
    end
  end
G
gitlabhq 已提交
139

R
randx 已提交
140 141 142
  #
  # Groups Area
  #
143
  resources :groups, constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/}  do
R
randx 已提交
144 145 146
    member do
      get :issues
      get :merge_requests
147
      get :members
R
randx 已提交
148
    end
149 150

    resources :users_groups, only: [:create, :update, :destroy]
R
randx 已提交
151 152
  end

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

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

157 158 159
  #
  # Project Area
  #
160
  resources :projects, constraints: { id: /[a-zA-Z.0-9_\-]+\/[a-zA-Z.0-9_\-]+/ }, except: [:new, :create, :index], path: "/" do
161 162
    member do
      put :transfer
163
      post :fork
164
      get :autocomplete_sources
165 166
    end

167
    scope module: :projects do
168 169 170 171 172 173 174 175 176 177 178 179
      resources :blob,    only: [:show], constraints: {id: /.+/}
      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 :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: /.+/}
      resources :network,   only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}
      resources :graphs, only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}
      match "/compare/:from...:to" => "compare#show", as: "compare", via: [:get, :post], constraints: {from: /.+/, to: /.+/}

180
        resources :snippets, constraints: {id: /\d+/} do
181 182 183
          member do
            get "raw"
          end
184 185
        end

186
      resources :wikis, only: [:show, :edit, :destroy, :create], constraints: {id: /[a-zA-Z.0-9_\-]+/} do
187 188 189 190 191
        collection do
          get :pages
          put ':id' => 'wikis#update'
          get :git_access
        end
D
Dmitriy Zaporozhets 已提交
192

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

198
      resource :wall, only: [:show], constraints: {id: /\d+/} do
199 200 201
        member do
          get 'notes'
        end
D
Dmitriy Zaporozhets 已提交
202 203
      end

204 205 206 207 208
      resource :repository, only: [:show] do
        member do
          get "stats"
          get "archive"
        end
D
Dmitriy Zaporozhets 已提交
209
      end
210

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

217
      resources :deploy_keys, constraints: {id: /\d+/} do
218 219 220 221
        member do
          put :enable
          put :disable
        end
222 223
      end

224
      resources :branches, only: [:index, :new, :create, :destroy], constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ } do
225 226 227 228 229
        collection do
          get :recent
        end
      end

230 231
      resources :tags, only: [:index, :new, :create, :destroy], constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ }
      resources :protected_branches, only: [:index, :create, :destroy], constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ }
M
miks 已提交
232

233 234 235 236
      resources :refs, only: [] do
        collection do
          get "switch"
        end
G
gitlabhq 已提交
237

238 239 240 241 242 243 244 245 246 247
        member do
          # tree viewer logs
          get "logs_tree", constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ }
          get "logs_tree/:path" => "refs#logs_tree",
            as: :logs_file,
            constraints: {
              id:   /[a-zA-Z.0-9\/_\-#%+]+/,
              path: /.*/
            }
        end
G
gitlabhq 已提交
248
      end
G
gitlabhq 已提交
249

250 251 252 253 254 255 256
      resources :merge_requests, constraints: {id: /\d+/}, except: [:destroy] do
        member do
          get :diffs
          get :automerge
          get :automerge_check
          get :ci_status
        end
257

258 259 260
        collection do
          get :branch_from
          get :branch_to
I
Izaak Alpert 已提交
261
          get :update_branches
262
        end
263
      end
264

265
      resources :hooks, only: [:index, :create, :destroy], constraints: {id: /\d+/} do
266 267 268
        member do
          get :test
        end
269
      end
270

271
      resources :team, controller: 'team_members', only: [:index]
272
      resources :milestones, except: [:destroy], constraints: {id: /\d+/}
273

274 275 276 277
      resources :labels, only: [:index] do
        collection do
          post :generate
        end
278 279
      end

280
      resources :issues, constraints: {id: /\d+/}, except: [:destroy] do
281 282 283
        collection do
          post  :bulk_update
        end
A
Adam Leonard 已提交
284
      end
R
Robert Speicher 已提交
285

286
      resources :team_members, except: [:index, :edit], constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ } do
287
        collection do
D
Dmitriy Zaporozhets 已提交
288

289 290 291 292 293
          # Used for import team
          # from another project
          get :import
          post :apply_import
        end
D
Dmitriy Zaporozhets 已提交
294 295
      end

296
      resources :notes, only: [:index, :create, :destroy, :update], constraints: {id: /\d+/} do
297
        member do
298
          delete :delete_attachment
299 300
        end

301 302 303 304
        collection do
          post :preview
        end
      end
305
    end
G
gitlabhq 已提交
306
  end
R
Robert Speicher 已提交
307

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