routes.rb 8.6 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
  #
J
Job van der Voort 已提交
34 35

  get 'help'                  => 'help#index'
36
  get 'help/:category/:file'  => 'help#show', as: :help_page
M
Marin Jankovski 已提交
37
  get 'help/shortcuts'
38

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

49 50 51 52 53 54 55 56
  #
  # Public namespace
  #
  namespace :public do
    resources :projects, only: [:index]
    root to: "projects#index"
  end

57 58 59
  #
  # Attachments serving
  #
60
  get 'files/:type/:id/:filename' => 'files#download', constraints: { id: /\d+/, type: /[a-z]+/, filename:  /.+/ }
61

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

74 75
    resources :groups, constraints: { id: /[^\/]+/ } do
      member do
A
Andrey Kumanyaev 已提交
76
        put :project_teams_update
77
      end
A
Andrey Kumanyaev 已提交
78
    end
A
Andrey Kumanyaev 已提交
79

R
Robert Speicher 已提交
80
    resources :hooks, only: [:index, :create, :destroy] do
V
Valeriy Sizov 已提交
81 82
      get :test
    end
A
Andrey Kumanyaev 已提交
83

84
    resources :broadcast_messages, only: [:index, :create, :destroy]
85
    resource :logs, only: [:show]
86
    resource :background_jobs, controller: 'background_jobs', only: [:show]
87 88 89 90 91 92 93

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

R
Robert Speicher 已提交
94
    root to: "dashboard#index"
G
gitlabhq 已提交
95 96
  end

R
randx 已提交
97 98 99
  #
  # Profile Area
  #
100 101 102 103 104 105 106 107
  resource :profile, only: [:show, :update] do
    member do
      get :history
      get :design

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

109
    scope module: :profiles do
110
      resource :account, only: [:show, :update]
111
      resource :notifications, only: [:show, :update]
112 113 114 115 116
      resource :password, only: [:new, :create, :edit, :update] do
        member do
          put :reset
        end
      end
117
      resources :keys
118
      resources :emails, only: [:index, :create, :destroy]
119 120 121 122 123
      resources :groups, only: [:index] do
        member do
          delete :leave
        end
      end
124
      resource :avatar, only: [:destroy]
125
    end
126
  end
R
Robert Speicher 已提交
127

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

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

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

    resources :users_groups, only: [:create, :update, :destroy]
S
Steven Thonus 已提交
153 154 155
    scope module: :groups do
      resource :avatar, only: [:destroy]
    end
R
randx 已提交
156 157
  end

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

160
  devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations , passwords: :passwords}
G
gitlabhq 已提交
161

162 163 164
  #
  # Project Area
  #
165
  resources :projects, constraints: { id: /[a-zA-Z.0-9_\-]+\/[a-zA-Z.0-9_\-]+/ }, except: [:new, :create, :index], path: "/" do
166 167
    member do
      put :transfer
168
      post :fork
169 170
      post :archive
      post :unarchive
171
      post :upload_image
172
      get :autocomplete_sources
173 174
      get :import
      put :retry_import
175 176
    end

177
    scope module: :projects do
178
      resources :blob,      only: [:show, :destroy], constraints: {id: /.+/}
179 180
      resources :raw,       only: [:show], constraints: {id: /.+/}
      resources :tree,      only: [:show], constraints: {id: /.+/, format: /(html|js)/ }
S
skv-headless 已提交
181 182 183
      resources :edit_tree, only: [:show, :update], constraints: { id: /.+/ }, path: 'edit' do
        post :preview, on: :member
      end
184 185 186 187 188
      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: /.+/}
189
      resources :network,   only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}
190 191
      resources :graphs,    only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}

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

194
        resources :snippets, constraints: {id: /\d+/} do
195 196 197
          member do
            get "raw"
          end
198 199
        end

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

207 208 209
        member do
          get "history"
        end
V
Valery Sizov 已提交
210
      end
V
Valery Sizov 已提交
211

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

218 219 220
      resource :repository, only: [:show] do
        member do
          get "stats"
221
          get "archive", constraints: { format: Gitlab::Regex.archive_formats_regex }
222
        end
D
Dmitriy Zaporozhets 已提交
223
      end
224

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

231
      resources :deploy_keys, constraints: {id: /\d+/} do
232 233 234 235
        member do
          put :enable
          put :disable
        end
236 237
      end

238
      resources :branches, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
239 240
      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 已提交
241

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

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

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

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

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

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

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

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

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

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

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

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

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

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