routes.rb 7.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
A
Andrey Kumanyaev 已提交
25
  }), at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) }
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

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

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

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

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

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

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

88
    resource :logs, only: [:show]
89
    resource :background_jobs, controller: 'background_jobs', only: [:show]
A
Andrey Kumanyaev 已提交
90

91
    resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:index, :show] do
92
      resources :members, only: [:destroy]
A
Andrey Kumanyaev 已提交
93 94
    end

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

98
  get "errors/githost"
R
randx 已提交
99 100 101 102

  #
  # Profile Area
  #
103 104 105 106 107 108 109 110 111 112 113
  resource :profile, only: [:show, :update] do
    member do
      get :account
      get :history
      get :token
      get :design

      put :update_password
      put :reset_private_token
      put :update_username
    end
D
Dmitriy Zaporozhets 已提交
114

115 116 117 118
    scope module: :profiles do
      resource :notifications, only: [:show, :update]
      resource :password, only: [:new, :create]
      resources :keys
119 120 121 122 123
      resources :groups, only: [:index] do
        member do
          delete :leave
        end
      end
124
    end
125
  end
R
Robert Speicher 已提交
126

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


D
Dmitriy Zaporozhets 已提交
130

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

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

    resources :users_groups, only: [:create, :update, :destroy]
R
randx 已提交
153 154
  end

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

M
Marin Jankovski 已提交
157
  devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations }
G
gitlabhq 已提交
158

159 160 161
  #
  # Project Area
  #
S
Sato Hiroyuki 已提交
162
  resources :projects, constraints: { id: /(?:[a-zA-Z.0-9_\-]+\/)?[a-zA-Z.0-9_\-]+/ }, except: [:new, :create, :index], path: "/" do
163 164
    member do
      put :transfer
165
      post :fork
166
      get :autocomplete_sources
167 168
    end

169
    scope module: :projects do
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
      resources :blob,    only: [:show], constraints: {id: /.+/}
      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 :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: /.+/}
      resources :network,   only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}
      resources :graphs, only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}
      match "/compare/:from...:to" => "compare#show", as: "compare", via: [:get, :post], constraints: {from: /.+/, to: /.+/}

        resources :snippets do
          member do
            get "raw"
          end
186 187
        end

188 189 190 191 192 193
      resources :wikis, only: [:show, :edit, :destroy, :create] do
        collection do
          get :pages
          put ':id' => 'wikis#update'
          get :git_access
        end
D
Dmitriy Zaporozhets 已提交
194

195 196 197
        member do
          get "history"
        end
V
Valery Sizov 已提交
198
      end
V
Valery Sizov 已提交
199

200 201 202 203
      resource :wall, only: [:show] do
        member do
          get 'notes'
        end
D
Dmitriy Zaporozhets 已提交
204 205
      end

206 207 208 209 210 211 212
      resource :repository, only: [:show] do
        member do
          get "branches"
          get "tags"
          get "stats"
          get "archive"
        end
D
Dmitriy Zaporozhets 已提交
213
      end
214

215 216 217 218
      resources :services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do
        member do
          get :test
        end
D
Dmitriy Zaporozhets 已提交
219 220
      end

221 222 223 224 225
      resources :deploy_keys do
        member do
          put :enable
          put :disable
        end
226 227
      end

228
      resources :protected_branches, only: [:index, :create, :destroy]
M
miks 已提交
229

230 231 232 233
      resources :refs, only: [] do
        collection do
          get "switch"
        end
G
gitlabhq 已提交
234

235 236 237 238 239 240 241 242 243 244
        member do
          # tree viewer logs
          get "logs_tree", constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ }
          get "logs_tree/:path" => "refs#logs_tree",
            as: :logs_file,
            constraints: {
              id:   /[a-zA-Z.0-9\/_\-#%+]+/,
              path: /.*/
            }
        end
G
gitlabhq 已提交
245
      end
G
gitlabhq 已提交
246

247 248 249 250 251 252 253
      resources :merge_requests, constraints: {id: /\d+/}, except: [:destroy] do
        member do
          get :diffs
          get :automerge
          get :automerge_check
          get :ci_status
        end
254

255 256 257 258
        collection do
          get :branch_from
          get :branch_to
        end
259
      end
260

261 262 263 264
      resources :hooks, only: [:index, :create, :destroy] do
        member do
          get :test
        end
265
      end
266

267 268
      resources :team, controller: 'team_members', only: [:index]
      resources :milestones, except: [:destroy]
269

270 271 272 273
      resources :labels, only: [:index] do
        collection do
          post :generate
        end
274 275
      end

276 277 278 279
      resources :issues, except: [:destroy] do
        collection do
          post  :bulk_update
        end
A
Adam Leonard 已提交
280
      end
R
Robert Speicher 已提交
281

282 283
      resources :team_members, except: [:index, :edit] do
        collection do
D
Dmitriy Zaporozhets 已提交
284

285 286 287 288 289
          # Used for import team
          # from another project
          get :import
          post :apply_import
        end
D
Dmitriy Zaporozhets 已提交
290 291
      end

292
      resources :notes, only: [:index, :create, :destroy, :update] do
293
        member do
294
          delete :delete_attachment
295 296
        end

297 298 299 300
        collection do
          post :preview
        end
      end
301
    end
G
gitlabhq 已提交
302
  end
R
Robert Speicher 已提交
303

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