routes.rb 8.5 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
25
  }), at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) }, via: [:get, :post]
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
  get 'help/security'
43

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

54 55 56 57 58 59 60 61
  #
  # Public namespace
  #
  namespace :public do
    resources :projects, only: [:index]
    root to: "projects#index"
  end

62 63 64
  #
  # Attachments serving
  #
65
  get 'files/:type/:id/:filename' => 'files#download', constraints: { id: /\d+/, type: /[a-z]+/, filename:  /.+/ }
66

67 68 69
  #
  # Admin Area
  #
N
Nihad Abbasov 已提交
70
  namespace :admin do
71
    resources :users, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do
72
      member do
D
Dmitriy Zaporozhets 已提交
73
        put :team_update
74 75
        put :block
        put :unblock
D
Dmitriy Zaporozhets 已提交
76 77
      end
    end
A
Andrey Kumanyaev 已提交
78

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

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

89
    resources :broadcast_messages, only: [:index, :create, :destroy]
90
    resource :logs, only: [:show]
91
    resource :background_jobs, controller: 'background_jobs', only: [:show]
92 93 94 95 96 97 98

    resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:index, :show] do
      member do
        put :transfer
      end
    end

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

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

  #
  # Profile Area
  #
107 108 109 110 111 112 113 114
  resource :profile, only: [:show, :update] do
    member do
      get :history
      get :design

      put :reset_private_token
      put :update_username
    end
D
Dmitriy Zaporozhets 已提交
115

116
    scope module: :profiles do
117
      resource :account, only: [:show, :update]
118
      resource :notifications, only: [:show, :update]
119 120 121 122 123
      resource :password, only: [:new, :create, :edit, :update] do
        member do
          put :reset
        end
      end
124
      resources :keys
125 126 127 128 129
      resources :groups, only: [:index] do
        member do
          delete :leave
        end
      end
130
      resource :avatar, only: [:destroy]
131
    end
132
  end
R
Robert Speicher 已提交
133

134
  match "/u/:username" => "users#show", as: :user, constraints: { username: /.*/ }, via: :get
D
Dmitriy Zaporozhets 已提交
135 136


D
Dmitriy Zaporozhets 已提交
137

R
randx 已提交
138 139 140
  #
  # Dashboard Area
  #
141
  resource :dashboard, controller: "dashboard", only: [:show] do
D
Dmitriy Zaporozhets 已提交
142 143 144 145 146 147
    member do
      get :projects
      get :issues
      get :merge_requests
    end
  end
G
gitlabhq 已提交
148

R
randx 已提交
149 150 151
  #
  # Groups Area
  #
152
  resources :groups, constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/}  do
R
randx 已提交
153 154 155
    member do
      get :issues
      get :merge_requests
156
      get :members
R
randx 已提交
157
    end
158 159

    resources :users_groups, only: [:create, :update, :destroy]
R
randx 已提交
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
  #
169
  resources :projects, constraints: { id: /[a-zA-Z.0-9_\-]+\/[a-zA-Z.0-9_\-]+/ }, except: [:new, :create, :index], path: "/" do
170 171
    member do
      put :transfer
172
      post :fork
173
      get :autocomplete_sources
174 175
    end

176
    scope module: :projects do
177
      resources :blob,      only: [:show, :destroy], constraints: {id: /.+/}
178 179 180 181 182 183 184 185
      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 :new_tree,  only: [:show, :update], constraints: {id: /.+/}, path: 'new'
      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: /.+/}
186
      resources :network,   only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}
187 188
      resources :graphs,    only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}

189 190
      match "/compare/:from...:to" => "compare#show", as: "compare", via: [:get, :post], constraints: {from: /.+/, to: /.+/}

191
        resources :snippets, constraints: {id: /\d+/} do
192 193 194
          member do
            get "raw"
          end
195 196
        end

197
      resources :wikis, only: [:show, :edit, :destroy, :create], constraints: {id: /[a-zA-Z.0-9_\-]+/} do
198 199 200 201 202
        collection do
          get :pages
          put ':id' => 'wikis#update'
          get :git_access
        end
D
Dmitriy Zaporozhets 已提交
203

204 205 206
        member do
          get "history"
        end
V
Valery Sizov 已提交
207
      end
V
Valery Sizov 已提交
208

209
      resource :wall, only: [:show], constraints: {id: /\d+/} do
210 211 212
        member do
          get 'notes'
        end
D
Dmitriy Zaporozhets 已提交
213 214
      end

215 216 217 218 219
      resource :repository, only: [:show] do
        member do
          get "stats"
          get "archive"
        end
D
Dmitriy Zaporozhets 已提交
220
      end
221

222 223 224 225
      resources :services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do
        member do
          get :test
        end
D
Dmitriy Zaporozhets 已提交
226 227
      end

228
      resources :deploy_keys, constraints: {id: /\d+/} do
229 230 231 232
        member do
          put :enable
          put :disable
        end
233 234
      end

235
      resources :branches, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex } do
236
        collection do
237
          get :recent, constraints: { id: Gitlab::Regex.git_reference_regex }
238 239 240
        end
      end

241 242
      resources :tags, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
      resources :protected_branches, only: [:index, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
M
miks 已提交
243

244 245 246 247
      resources :refs, only: [] do
        collection do
          get "switch"
        end
G
gitlabhq 已提交
248

249 250
        member do
          # tree viewer logs
251
          get "logs_tree", constraints: { id: Gitlab::Regex.git_reference_regex }
252 253 254
          get "logs_tree/:path" => "refs#logs_tree",
            as: :logs_file,
            constraints: {
255
              id:   Gitlab::Regex.git_reference_regex,
256 257 258
              path: /.*/
            }
        end
G
gitlabhq 已提交
259
      end
G
gitlabhq 已提交
260

261 262 263 264 265 266 267
      resources :merge_requests, constraints: {id: /\d+/}, except: [:destroy] do
        member do
          get :diffs
          get :automerge
          get :automerge_check
          get :ci_status
        end
268

269 270 271
        collection do
          get :branch_from
          get :branch_to
I
Izaak Alpert 已提交
272
          get :update_branches
273
        end
274
      end
275

276
      resources :hooks, only: [:index, :create, :destroy], constraints: {id: /\d+/} do
277 278 279
        member do
          get :test
        end
280
      end
281

282
      resources :team, controller: 'team_members', only: [:index]
283
      resources :milestones, except: [:destroy], constraints: {id: /\d+/}
284

285 286 287 288
      resources :labels, only: [:index] do
        collection do
          post :generate
        end
289 290
      end

291
      resources :issues, constraints: {id: /\d+/}, except: [:destroy] do
292 293 294
        collection do
          post  :bulk_update
        end
A
Adam Leonard 已提交
295
      end
R
Robert Speicher 已提交
296

297
      resources :team_members, except: [:index, :edit], constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ } do
298
        collection do
299
          delete :leave
D
Dmitriy Zaporozhets 已提交
300

301 302 303 304 305
          # Used for import team
          # from another project
          get :import
          post :apply_import
        end
D
Dmitriy Zaporozhets 已提交
306 307
      end

308
      resources :notes, only: [:index, :create, :destroy, :update], constraints: {id: /\d+/} do
309
        member do
310
          delete :delete_attachment
311 312
        end

313 314 315 316
        collection do
          post :preview
        end
      end
317
    end
G
gitlabhq 已提交
318
  end
R
Robert Speicher 已提交
319

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