routes.rb 9.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"
9
  get 'search/autocomplete' => "search#autocomplete", as: :search_autocomplete
V
Valery Sizov 已提交
10

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

G
GitLab 已提交
15
  # Get all keys of user
16 17
  get ':username.keys' => 'profiles/keys#get_keys' , constraints: { username: /.*/ }

D
sidekiq  
Dmitriy Zaporozhets 已提交
18 19
  constraint = lambda { |request| request.env["warden"].authenticate? and request.env['warden'].user.admin? }
  constraints constraint do
20
    mount Sidekiq::Web, at: "/admin/sidekiq", as: :sidekiq
D
sidekiq  
Dmitriy Zaporozhets 已提交
21
  end
A
Ariejan de Vroom 已提交
22

23 24
  # Enable Grack support
  mount Grack::Bundle.new({
25
    git_path:     Gitlab.config.git.bin_path,
26 27 28
    project_root: Gitlab.config.gitlab_shell.repos_path,
    upload_pack:  Gitlab.config.gitlab_shell.upload_pack,
    receive_pack: Gitlab.config.gitlab_shell.receive_pack
29
  }), at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) }, via: [:get, :post]
30

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

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

58 59 60 61 62 63 64 65
  #
  # Public namespace
  #
  namespace :public do
    resources :projects, only: [:index]
    root to: "projects#index"
  end

66 67 68
  #
  # Attachments serving
  #
69
  get 'files/:type/:id/:filename' => 'files#download', constraints: { id: /\d+/, type: /[a-z]+/, filename:  /.+/ }
70

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

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

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

93
    resources :broadcast_messages, only: [:index, :create, :destroy]
94
    resource :logs, only: [:show]
95
    resource :background_jobs, controller: 'background_jobs', only: [:show]
96 97 98 99 100 101 102

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

R
Robert Speicher 已提交
103
    root to: "dashboard#index"
G
gitlabhq 已提交
104 105
  end

R
randx 已提交
106 107 108
  #
  # Profile Area
  #
109 110 111 112 113 114 115 116
  resource :profile, only: [:show, :update] do
    member do
      get :history
      get :design

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

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

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


D
Dmitriy Zaporozhets 已提交
140

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

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

    resources :users_groups, only: [:create, :update, :destroy]
S
Steven Thonus 已提交
163 164 165
    scope module: :groups do
      resource :avatar, only: [:destroy]
    end
R
randx 已提交
166 167
  end

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

170
  devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations , passwords: :passwords}
G
gitlabhq 已提交
171

172 173 174
  #
  # Project Area
  #
175
  resources :projects, constraints: { id: /[a-zA-Z.0-9_\-]+\/[a-zA-Z.0-9_\-]+/ }, except: [:new, :create, :index], path: "/" do
176 177
    member do
      put :transfer
178
      post :fork
179 180
      post :archive
      post :unarchive
181
      get :autocomplete_sources
182 183
      get :import
      put :retry_import
184 185
    end

186
    scope module: :projects do
187
      resources :blob,      only: [:show, :destroy], constraints: {id: /.+/}
188 189 190 191 192 193 194 195
      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: /.+/}
196
      resources :network,   only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}
197 198
      resources :graphs,    only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}

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

201
        resources :snippets, constraints: {id: /\d+/} do
202 203 204
          member do
            get "raw"
          end
205 206
        end

207
      resources :wikis, only: [:show, :edit, :destroy, :create], constraints: {id: /[a-zA-Z.0-9_\-]+/} do
208 209 210 211 212
        collection do
          get :pages
          put ':id' => 'wikis#update'
          get :git_access
        end
D
Dmitriy Zaporozhets 已提交
213

214 215 216
        member do
          get "history"
        end
V
Valery Sizov 已提交
217
      end
V
Valery Sizov 已提交
218

219
      resource :wall, only: [:show], constraints: {id: /\d+/} do
220 221 222
        member do
          get 'notes'
        end
D
Dmitriy Zaporozhets 已提交
223 224
      end

225 226 227
      resource :repository, only: [:show] do
        member do
          get "stats"
228
          get "archive", constraints: { format: Gitlab::Regex.archive_formats_regex }
229
        end
D
Dmitriy Zaporozhets 已提交
230
      end
231

232 233 234 235
      resources :services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do
        member do
          get :test
        end
D
Dmitriy Zaporozhets 已提交
236 237
      end

238
      resources :deploy_keys, constraints: {id: /\d+/} do
239 240 241 242
        member do
          put :enable
          put :disable
        end
243 244
      end

245
      resources :branches, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex } do
246
        collection do
247
          get :recent, constraints: { id: Gitlab::Regex.git_reference_regex }
248 249 250
        end
      end

251 252
      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 已提交
253

254 255 256 257
      resources :refs, only: [] do
        collection do
          get "switch"
        end
G
gitlabhq 已提交
258

259 260
        member do
          # tree viewer logs
261
          get "logs_tree", constraints: { id: Gitlab::Regex.git_reference_regex }
262 263 264
          get "logs_tree/:path" => "refs#logs_tree",
            as: :logs_file,
            constraints: {
265
              id:   Gitlab::Regex.git_reference_regex,
266 267 268
              path: /.*/
            }
        end
G
gitlabhq 已提交
269
      end
G
gitlabhq 已提交
270

271 272 273 274 275 276 277
      resources :merge_requests, constraints: {id: /\d+/}, except: [:destroy] do
        member do
          get :diffs
          get :automerge
          get :automerge_check
          get :ci_status
        end
278

279 280 281
        collection do
          get :branch_from
          get :branch_to
I
Izaak Alpert 已提交
282
          get :update_branches
283
        end
284
      end
285

286
      resources :hooks, only: [:index, :create, :destroy], constraints: {id: /\d+/} do
287 288 289
        member do
          get :test
        end
290
      end
291

292
      resources :team, controller: 'team_members', only: [:index]
293
      resources :milestones, except: [:destroy], constraints: {id: /\d+/}
294

295 296 297 298
      resources :labels, only: [:index] do
        collection do
          post :generate
        end
299 300
      end

301
      resources :issues, constraints: {id: /\d+/}, except: [:destroy] do
302 303 304
        collection do
          post  :bulk_update
        end
A
Adam Leonard 已提交
305
      end
R
Robert Speicher 已提交
306

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

311 312 313 314 315
          # Used for import team
          # from another project
          get :import
          post :apply_import
        end
D
Dmitriy Zaporozhets 已提交
316 317
      end

318
      resources :notes, only: [:index, :create, :destroy, :update], constraints: {id: /\d+/} do
319
        member do
320
          delete :delete_attachment
321 322
        end

323 324 325 326
        collection do
          post :preview
        end
      end
327
    end
G
gitlabhq 已提交
328
  end
R
Robert Speicher 已提交
329

G
GitLab 已提交
330 331
  get ':id' => "groups#show", constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/}

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