routes.rb 8.9 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
  #
  # Public namespace
  #
  namespace :public do
    resources :projects, only: [:index]
54
    resources :groups, only: [:index]
D
Dmitriy Zaporozhets 已提交
55 56
    get 'explore' => 'explore#index'
    root to: "explore#index"
57 58
  end

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

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

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

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

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

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

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

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

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

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

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

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

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

    resources :users_groups, only: [:create, :update, :destroy]
156

S
Steven Thonus 已提交
157 158
    scope module: :groups do
      resource :avatar, only: [:destroy]
159
      resources :milestones
S
Steven Thonus 已提交
160
    end
R
randx 已提交
161 162
  end

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

165
  devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations , passwords: :passwords, sessions: :sessions }
G
gitlabhq 已提交
166

167 168 169
  devise_scope :user do
    get "/users/auth/:provider/omniauth_error" => "omniauth_callbacks#omniauth_error", as: :omniauth_error
  end
170 171 172
  #
  # Project Area
  #
173
  resources :projects, constraints: { id: /[a-zA-Z.0-9_\-]+\/[a-zA-Z.0-9_\-]+/ }, except: [:new, :create, :index], path: "/" do
174 175
    member do
      put :transfer
176
      post :fork
177 178
      post :archive
      post :unarchive
179
      post :upload_image
180
      get :autocomplete_sources
181 182
      get :import
      put :retry_import
183 184
    end

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

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

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

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

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

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

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

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

240
      resources :branches, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
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
      resources :merge_requests, constraints: {id: /\d+/}, except: [:destroy] do
        member do
          get :diffs
264
          post :automerge
265 266 267
          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]
D
Dmitriy Zaporozhets 已提交
283 284 285
      resources :milestones, except: [:destroy], constraints: {id: /\d+/} do
        member do
          put :sort_issues
286
          put :sort_merge_requests
D
Dmitriy Zaporozhets 已提交
287 288
        end
      end
289

290 291 292 293
      resources :labels, only: [:index] do
        collection do
          post :generate
        end
294 295
      end

296
      resources :issues, constraints: {id: /\d+/}, except: [:destroy] do
297 298 299
        collection do
          post  :bulk_update
        end
A
Adam Leonard 已提交
300
      end
R
Robert Speicher 已提交
301

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

306 307 308 309 310
          # Used for import team
          # from another project
          get :import
          post :apply_import
        end
D
Dmitriy Zaporozhets 已提交
311 312
      end

313
      resources :notes, only: [:index, :create, :destroy, :update], constraints: {id: /\d+/} do
314
        member do
315
          delete :delete_attachment
316 317
        end

318 319 320 321
        collection do
          post :preview
        end
      end
322
    end
G
gitlabhq 已提交
323
  end
R
Robert Speicher 已提交
324

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

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