routes.rb 7.0 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
      scope module: :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do
92
        resources :members, only: [:destroy]
A
Andrey Kumanyaev 已提交
93 94 95
      end
    end

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

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

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

    resource :notifications
117
    resource :password
118
  end
R
Robert Speicher 已提交
119

120
  resources :keys
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
  #
D
Dmitriy Zaporozhets 已提交
128 129 130 131 132 133 134
  resource :dashboard, controller: "dashboard" do
    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
    resources :blob,    only: [:show], constraints: {id: /.+/}
164
    resources :raw,    only: [:show], constraints: {id: /.+/}
165 166
    resources :tree,    only: [:show], constraints: {id: /.+/, format: /(html|js)/ }
    resources :edit_tree,    only: [:show, :update], constraints: {id: /.+/}, path: 'edit'
D
Dmitriy Zaporozhets 已提交
167
    resources :commit,  only: [:show], constraints: {id: /[[:alnum:]]{6,40}/}
S
Sato Hiroyuki 已提交
168
    resources :commits, only: [:show], constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/}
D
Dmitriy Zaporozhets 已提交
169 170
    resources :compare, only: [:index, :create]
    resources :blame,   only: [:show], constraints: {id: /.+/}
171 172
    resources :network,   only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}
    resources :graphs, only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}
173
    match "/compare/:from...:to" => "compare#show", as: "compare", via: [:get, :post], constraints: {from: /.+/, to: /.+/}
D
Dmitriy Zaporozhets 已提交
174

175 176 177 178 179 180 181 182
    scope module: :projects do
      resources :snippets do
        member do
          get "raw"
        end
      end
    end

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

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

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

201 202
    resource :repository do
      member do
D
Dmitriy Zaporozhets 已提交
203 204
        get "branches"
        get "tags"
R
randx 已提交
205
        get "stats"
206
        get "archive"
D
Dmitriy Zaporozhets 已提交
207 208
      end
    end
209

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

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

R
Robert Speicher 已提交
223
    resources :protected_branches, only: [:index, :create, :destroy]
M
miks 已提交
224

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

230
      member do
231
        # tree viewer logs
232
        get "logs_tree", constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ }
R
randx 已提交
233
        get "logs_tree/:path" => "refs#logs_tree",
R
Robert Speicher 已提交
234 235
          as: :logs_file,
          constraints: {
236
            id:   /[a-zA-Z.0-9\/_\-#%+]+/,
R
Robert Speicher 已提交
237
            path: /.*/
R
randx 已提交
238
          }
G
gitlabhq 已提交
239
      end
G
gitlabhq 已提交
240
    end
G
gitlabhq 已提交
241

D
Dmitriy Zaporozhets 已提交
242
    resources :merge_requests, constraints: {id: /\d+/}, except: [:destroy] do
243
      member do
244
        get :diffs
R
randx 已提交
245
        get :automerge
V
Valery Sizov 已提交
246
        get :automerge_check
247
        get :ci_status
248
      end
249

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

R
Robert Speicher 已提交
256
    resources :hooks, only: [:index, :create, :destroy] do
257
      member do
258 259 260
        get :test
      end
    end
261

R
Robert Speicher 已提交
262
    resources :team, controller: 'team_members', only: [:index]
D
Dmitriy Zaporozhets 已提交
263
    resources :milestones, except: [:destroy]
264 265 266 267 268 269 270

    resources :labels, only: [:index] do
      collection do
        post :generate
      end
    end

D
Dmitriy Zaporozhets 已提交
271
    resources :issues, except: [:destroy] do
V
VSizov 已提交
272
      collection do
R
randx 已提交
273
        post  :bulk_update
A
Adam Leonard 已提交
274
      end
V
VSizov 已提交
275
    end
R
Robert Speicher 已提交
276

277
    resources :team_members, except: [:index, :edit] do
D
Dmitriy Zaporozhets 已提交
278 279 280 281 282 283 284 285 286
      collection do

        # Used for import team
        # from another project
        get :import
        post :apply_import
      end
    end

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

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