routes.rb 7.3 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'
41

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

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

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

65 66 67
  #
  # Admin Area
  #
N
Nihad Abbasov 已提交
68
  namespace :admin do
69
    resources :users, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do
70
      member do
D
Dmitriy Zaporozhets 已提交
71
        put :team_update
72 73
        put :block
        put :unblock
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
    resource :logs, only: [:show]
88
    resource :background_jobs, controller: 'background_jobs', only: [:show]
A
Andrey Kumanyaev 已提交
89

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

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

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

  #
  # Profile Area
  #
102 103 104 105 106 107 108 109 110 111 112
  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 已提交
113

114 115 116 117 118
    scope module: :profiles do
      resource :notifications, only: [:show, :update]
      resource :password, only: [:new, :create]
      resources :keys
    end
119
  end
R
Robert Speicher 已提交
120

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


D
Dmitriy Zaporozhets 已提交
124

R
randx 已提交
125 126 127
  #
  # Dashboard Area
  #
128
  resource :dashboard, controller: "dashboard", only: [:show] do
D
Dmitriy Zaporozhets 已提交
129 130 131 132 133 134
    member do
      get :projects
      get :issues
      get :merge_requests
    end
  end
G
gitlabhq 已提交
135

R
randx 已提交
136 137 138
  #
  # Groups Area
  #
139
  resources :groups, constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/}  do
R
randx 已提交
140 141 142 143 144
    member do
      get :issues
      get :merge_requests
      get :people
    end
145 146

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

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

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

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

163
    scope module: :projects do
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
      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
180 181
        end

182 183 184 185 186 187
      resources :wikis, only: [:show, :edit, :destroy, :create] do
        collection do
          get :pages
          put ':id' => 'wikis#update'
          get :git_access
        end
D
Dmitriy Zaporozhets 已提交
188

189 190 191
        member do
          get "history"
        end
V
Valery Sizov 已提交
192
      end
V
Valery Sizov 已提交
193

194 195 196 197
      resource :wall, only: [:show] do
        member do
          get 'notes'
        end
D
Dmitriy Zaporozhets 已提交
198 199
      end

200 201 202 203 204 205 206
      resource :repository, only: [:show] do
        member do
          get "branches"
          get "tags"
          get "stats"
          get "archive"
        end
D
Dmitriy Zaporozhets 已提交
207
      end
208

209 210 211 212
      resources :services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do
        member do
          get :test
        end
D
Dmitriy Zaporozhets 已提交
213 214
      end

215 216 217 218 219
      resources :deploy_keys do
        member do
          put :enable
          put :disable
        end
220 221
      end

222
      resources :protected_branches, only: [:index, :create, :destroy]
M
miks 已提交
223

224 225 226 227
      resources :refs, only: [] do
        collection do
          get "switch"
        end
G
gitlabhq 已提交
228

229 230 231 232 233 234 235 236 237 238
        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 已提交
239
      end
G
gitlabhq 已提交
240

241 242 243 244 245 246 247
      resources :merge_requests, constraints: {id: /\d+/}, except: [:destroy] do
        member do
          get :diffs
          get :automerge
          get :automerge_check
          get :ci_status
        end
248

249 250 251 252
        collection do
          get :branch_from
          get :branch_to
        end
253
      end
254

255 256 257 258
      resources :hooks, only: [:index, :create, :destroy] do
        member do
          get :test
        end
259
      end
260

261 262
      resources :team, controller: 'team_members', only: [:index]
      resources :milestones, except: [:destroy]
263

264 265 266 267
      resources :labels, only: [:index] do
        collection do
          post :generate
        end
268 269
      end

270 271 272 273
      resources :issues, except: [:destroy] do
        collection do
          post  :bulk_update
        end
A
Adam Leonard 已提交
274
      end
R
Robert Speicher 已提交
275

276 277
      resources :team_members, except: [:index, :edit] do
        collection do
D
Dmitriy Zaporozhets 已提交
278

279 280 281 282 283
          # Used for import team
          # from another project
          get :import
          post :apply_import
        end
D
Dmitriy Zaporozhets 已提交
284 285
      end

286 287 288 289 290
      resources :notes, only: [:index, :create, :destroy] do
        collection do
          post :preview
        end
      end
291
      end
G
gitlabhq 已提交
292
  end
R
Robert Speicher 已提交
293

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