routes.rb 9.7 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
V
Valery Sizov 已提交
5 6 7 8 9
  use_doorkeeper do
    controllers :applications => 'oauth/applications',
                :authorized_applications => 'oauth/authorized_applications',
                :authorizations => 'oauth/authorizations'
  end
10 11 12
  #
  # Search
  #
13
  get 'search' => "search#show"
14
  get 'search/autocomplete' => "search#autocomplete", as: :search_autocomplete
V
Valery Sizov 已提交
15

16
  # API
17 18
  API::API.logger Rails.logger
  mount API::API => '/api'
19

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

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

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

36 37 38
  #
  # Help
  #
J
Job van der Voort 已提交
39 40

  get 'help'                  => 'help#index'
41
  get 'help/:category/:file'  => 'help#show', as: :help_page
M
Marin Jankovski 已提交
42
  get 'help/shortcuts'
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
  #
D
Dmitriy Zaporozhets 已提交
55
  # Explroe area
56
  #
D
Dmitriy Zaporozhets 已提交
57 58 59 60
  namespace :explore do
    resources :projects, only: [:index] do
      collection do
        get :trending
61
        get :starred
D
Dmitriy Zaporozhets 已提交
62 63 64
      end
    end

65
    resources :groups, only: [:index]
D
Dmitriy Zaporozhets 已提交
66
    root to: "projects#trending"
67 68
  end

D
Dmitriy Zaporozhets 已提交
69 70 71 72
  # Compatibility with old routing
  get 'public' => "explore/projects#index"
  get 'public/projects' => "explore/projects#index"

73 74 75
  #
  # Attachments serving
  #
76
  get 'files/:type/:id/:filename' => 'files#download', constraints: { id: /\d+/, type: /[a-z]+/, filename:  /.+/ }
77

78 79 80
  #
  # Admin Area
  #
N
Nihad Abbasov 已提交
81
  namespace :admin do
82
    resources :users, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do
83
      resources :keys, only: [:show, :destroy]
84
      member do
D
Dmitriy Zaporozhets 已提交
85
        put :team_update
86 87
        put :block
        put :unblock
88
        delete 'remove/:email_id', action: 'remove_email', as: 'remove_email'
D
Dmitriy Zaporozhets 已提交
89 90
      end
    end
A
Andrey Kumanyaev 已提交
91

92 93
    resources :groups, constraints: { id: /[^\/]+/ } do
      member do
A
Andrey Kumanyaev 已提交
94
        put :project_teams_update
95
      end
A
Andrey Kumanyaev 已提交
96
    end
A
Andrey Kumanyaev 已提交
97

R
Robert Speicher 已提交
98
    resources :hooks, only: [:index, :create, :destroy] do
V
Valeriy Sizov 已提交
99 100
      get :test
    end
A
Andrey Kumanyaev 已提交
101

102
    resources :broadcast_messages, only: [:index, :create, :destroy]
103
    resource :logs, only: [:show]
104
    resource :background_jobs, controller: 'background_jobs', only: [:show]
105 106 107 108 109 110 111

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

R
Robert Speicher 已提交
112
    root to: "dashboard#index"
G
gitlabhq 已提交
113 114
  end

R
randx 已提交
115 116 117
  #
  # Profile Area
  #
118 119 120 121
  resource :profile, only: [:show, :update] do
    member do
      get :history
      get :design
D
Dmitriy Zaporozhets 已提交
122
      get :applications
123 124 125 126

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

128
    scope module: :profiles do
129
      resource :account, only: [:show, :update]
130
      resource :notifications, only: [:show, :update]
131 132 133 134 135
      resource :password, only: [:new, :create, :edit, :update] do
        member do
          put :reset
        end
      end
136
      resources :keys
137
      resources :emails, only: [:index, :create, :destroy]
138 139 140 141 142
      resources :groups, only: [:index] do
        member do
          delete :leave
        end
      end
143
      resource :avatar, only: [:destroy]
144
    end
145
  end
R
Robert Speicher 已提交
146

147 148
  match "/u/:username" => "users#show", as: :user,
    constraints: {username: /(?:[^.]|\.(?!atom$))+/, format: /atom/}, via: :get
D
Dmitriy Zaporozhets 已提交
149

R
randx 已提交
150 151 152
  #
  # Dashboard Area
  #
153
  resource :dashboard, controller: "dashboard", only: [:show] do
D
Dmitriy Zaporozhets 已提交
154 155 156 157 158 159
    member do
      get :projects
      get :issues
      get :merge_requests
    end
  end
G
gitlabhq 已提交
160

R
randx 已提交
161 162 163
  #
  # Groups Area
  #
164
  resources :groups, constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/}  do
R
randx 已提交
165 166 167
    member do
      get :issues
      get :merge_requests
168
      get :members
D
Dmitriy Zaporozhets 已提交
169
      get :projects
R
randx 已提交
170
    end
171

S
Steven Thonus 已提交
172
    scope module: :groups do
173
      resources :group_members, only: [:create, :update, :destroy]
S
Steven Thonus 已提交
174
      resource :avatar, only: [:destroy]
175
      resources :milestones
S
Steven Thonus 已提交
176
    end
R
randx 已提交
177 178
  end

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

181
  devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations , passwords: :passwords, sessions: :sessions, confirmations: :confirmations }
G
gitlabhq 已提交
182

183 184 185
  devise_scope :user do
    get "/users/auth/:provider/omniauth_error" => "omniauth_callbacks#omniauth_error", as: :omniauth_error
  end
186 187 188
  #
  # Project Area
  #
189
  resources :projects, constraints: { id: /[a-zA-Z.0-9_\-]+\/[a-zA-Z.0-9_\-]+/ }, except: [:new, :create, :index], path: "/" do
190 191
    member do
      put :transfer
192 193
      post :archive
      post :unarchive
194
      post :upload_image
C
Ciro Santilli 已提交
195
      post :toggle_star
196
      get :markdown_preview
197
      get :autocomplete_sources
198 199
    end

200
    scope module: :projects do
201
      resources :blob, only: [:show, :destroy], constraints: { id: /.+/, format: false } do
S
skv 已提交
202 203
        get :diff, on: :member
      end
204 205
      resources :raw,       only: [:show], constraints: {id: /.+/}
      resources :tree,      only: [:show], constraints: {id: /.+/, format: /(html|js)/ }
S
skv-headless 已提交
206
      resources :edit_tree, only: [:show, :update], constraints: { id: /.+/ }, path: 'edit' do
C
Ciro Santilli 已提交
207
        # Cannot be GET to differentiate from GET paths that end in preview.
S
skv-headless 已提交
208 209
        post :preview, on: :member
      end
210 211 212 213 214
      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: /.+/}
215
      resources :network,   only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}
216 217 218 219 220
      resources :graphs,    only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/} do
        member do
          get :commits
        end
      end
221

222 223
      get '/compare/:from...:to' => 'compare#show', :as => 'compare',
          :constraints => {from: /.+/, to: /.+/}
224

225 226 227
      resources :snippets, constraints: {id: /\d+/} do
        member do
          get "raw"
228
        end
229
      end
230

M
Marin Jankovski 已提交
231
      resources :wikis, only: [:show, :edit, :destroy, :create], constraints: {id: /[a-zA-Z.0-9_\-\/]+/} do
232 233 234 235 236
        collection do
          get :pages
          put ':id' => 'wikis#update'
          get :git_access
        end
D
Dmitriy Zaporozhets 已提交
237

238 239 240
        member do
          get "history"
        end
V
Valery Sizov 已提交
241
      end
V
Valery Sizov 已提交
242

243
      resource :fork, only: [:new, :create]
244
      resource :import, only: [:new, :create, :show]
245

246
      resource :repository, only: [:show, :create] do
247
        member do
248
          get "archive", constraints: { format: Gitlab::Regex.archive_formats_regex }
249
        end
D
Dmitriy Zaporozhets 已提交
250
      end
251

252 253 254 255
      resources :services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do
        member do
          get :test
        end
D
Dmitriy Zaporozhets 已提交
256 257
      end

258
      resources :deploy_keys, constraints: {id: /\d+/} do
259 260 261 262
        member do
          put :enable
          put :disable
        end
263 264
      end

265
      resources :branches, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
266
      resources :tags, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
267
      resources :protected_branches, only: [:index, :create, :update, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
M
miks 已提交
268

269 270 271 272
      resources :refs, only: [] do
        collection do
          get "switch"
        end
G
gitlabhq 已提交
273

274 275
        member do
          # tree viewer logs
276
          get "logs_tree", constraints: { id: Gitlab::Regex.git_reference_regex }
277 278 279
          get "logs_tree/:path" => "refs#logs_tree",
            as: :logs_file,
            constraints: {
280
              id:   Gitlab::Regex.git_reference_regex,
281 282 283
              path: /.*/
            }
        end
G
gitlabhq 已提交
284
      end
G
gitlabhq 已提交
285

286 287 288
      resources :merge_requests, constraints: {id: /\d+/}, except: [:destroy] do
        member do
          get :diffs
289
          post :automerge
290 291 292
          get :automerge_check
          get :ci_status
        end
293

294 295 296
        collection do
          get :branch_from
          get :branch_to
I
Izaak Alpert 已提交
297
          get :update_branches
298
        end
299
      end
300

301
      resources :hooks, only: [:index, :create, :destroy], constraints: {id: /\d+/} do
302 303 304
        member do
          get :test
        end
305
      end
306

307
      resources :team, controller: 'team_members', only: [:index]
D
Dmitriy Zaporozhets 已提交
308 309 310
      resources :milestones, except: [:destroy], constraints: {id: /\d+/} do
        member do
          put :sort_issues
311
          put :sort_merge_requests
D
Dmitriy Zaporozhets 已提交
312 313
        end
      end
314

315
      resources :labels, constraints: {id: /\d+/} do
316 317 318
        collection do
          post :generate
        end
319 320
      end

321
      resources :issues, constraints: {id: /\d+/}, except: [:destroy] do
322 323 324
        collection do
          post  :bulk_update
        end
A
Adam Leonard 已提交
325
      end
R
Robert Speicher 已提交
326

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

331 332 333 334 335
          # Used for import team
          # from another project
          get :import
          post :apply_import
        end
D
Dmitriy Zaporozhets 已提交
336 337
      end

338
      resources :notes, only: [:index, :create, :destroy, :update], constraints: {id: /\d+/} do
339
        member do
340
          delete :delete_attachment
341
        end
342
      end
343
    end
G
gitlabhq 已提交
344
  end
R
Robert Speicher 已提交
345

D
Dmitriy Zaporozhets 已提交
346
  get ':id' => "namespaces#show", constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/}
G
GitLab 已提交
347

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