routes.rb 9.31 KB
Newer Older
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
1
require 'sidekiq/web'
2
require 'api/api'
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
3

gitlabhq's avatar
gitlabhq committed
4
Gitlab::Application.routes.draw do
5 6 7
  #
  # Search
  #
8
  get 'search' => "search#show"
9
  get 'search/autocomplete' => "search#autocomplete", as: :search_autocomplete
Valery Sizov's avatar
Valery Sizov committed
10

11
  # API
12 13
  API::API.logger Rails.logger
  mount API::API => '/api'
14

GitLab's avatar
GitLab committed
15
  # Get all keys of user
16 17
  get ':username.keys' => 'profiles/keys#get_keys' , constraints: { username: /.*/ }

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
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
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
21
  end
Ariejan de Vroom's avatar
Ariejan de Vroom committed
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
  #
Job van der Voort's avatar
Job van der Voort committed
34 35

  get 'help'                  => 'help#index'
36
  get 'help/:category/:file'  => 'help#show', as: :help_page
Marin Jankovski's avatar
Marin Jankovski committed
37
  get 'help/shortcuts'
38

Andrew8xx8's avatar
Andrew8xx8 committed
39 40 41 42 43 44 45 46
  #
  # Global snippets
  #
  resources :snippets do
    member do
      get "raw"
    end
  end
Andrew8xx8's avatar
Andrew8xx8 committed
47
  get "/s/:username" => "snippets#user_index", as: :user_snippets, constraints: { username: /.*/ }
Andrew8xx8's avatar
Andrew8xx8 committed
48

49
  #
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
50
  # Explroe area
51
  #
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
52 53 54 55
  namespace :explore do
    resources :projects, only: [:index] do
      collection do
        get :trending
56
        get :starred
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
57 58 59
      end
    end

60
    resources :groups, only: [:index]
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
61
    root to: "projects#trending"
62 63
  end

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
64 65 66 67
  # Compatibility with old routing
  get 'public' => "explore/projects#index"
  get 'public/projects' => "explore/projects#index"

68 69 70
  #
  # Attachments serving
  #
71
  get 'files/:type/:id/:filename' => 'files#download', constraints: { id: /\d+/, type: /[a-z]+/, filename:  /.+/ }
72

73 74 75
  #
  # Admin Area
  #
Nihad Abbasov's avatar
Nihad Abbasov committed
76
  namespace :admin do
77
    resources :users, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do
78
      member do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
79
        put :team_update
80 81
        put :block
        put :unblock
82
        delete 'remove/:email_id', action: 'remove_email', as: 'remove_email'
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
83 84
      end
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
85

86 87
    resources :groups, constraints: { id: /[^\/]+/ } do
      member do
88
        put :project_teams_update
89
      end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
90
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
91

92
    resources :hooks, only: [:index, :create, :destroy] do
Valeriy Sizov's avatar
Valeriy Sizov committed
93 94
      get :test
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
95

96
    resources :broadcast_messages, only: [:index, :create, :destroy]
97
    resource :logs, only: [:show]
98
    resource :background_jobs, controller: 'background_jobs', only: [:show]
99 100 101 102 103 104 105

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

106
    root to: "dashboard#index"
gitlabhq's avatar
gitlabhq committed
107 108
  end

randx's avatar
randx committed
109 110 111
  #
  # Profile Area
  #
112 113 114 115 116 117 118 119
  resource :profile, only: [:show, :update] do
    member do
      get :history
      get :design

      put :reset_private_token
      put :update_username
    end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
120

121
    scope module: :profiles do
122
      resource :account, only: [:show, :update]
123
      resource :notifications, only: [:show, :update]
124 125 126 127 128
      resource :password, only: [:new, :create, :edit, :update] do
        member do
          put :reset
        end
      end
129
      resources :keys
130
      resources :emails, only: [:index, :create, :destroy]
131 132 133 134 135
      resources :groups, only: [:index] do
        member do
          delete :leave
        end
      end
136
      resource :avatar, only: [:destroy]
137
    end
138
  end
139

140 141
  match "/u/:username" => "users#show", as: :user,
    constraints: {username: /(?:[^.]|\.(?!atom$))+/, format: /atom/}, via: :get
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
142

randx's avatar
randx committed
143 144 145
  #
  # Dashboard Area
  #
146
  resource :dashboard, controller: "dashboard", only: [:show] do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
147 148 149 150 151 152
    member do
      get :projects
      get :issues
      get :merge_requests
    end
  end
gitlabhq's avatar
gitlabhq committed
153

randx's avatar
randx committed
154 155 156
  #
  # Groups Area
  #
157
  resources :groups, constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/}  do
randx's avatar
randx committed
158 159 160
    member do
      get :issues
      get :merge_requests
161
      get :members
162
      get :projects
randx's avatar
randx committed
163
    end
164

Steven Thonus's avatar
Steven Thonus committed
165
    scope module: :groups do
166
      resources :group_members, only: [:create, :update, :destroy]
Steven Thonus's avatar
Steven Thonus committed
167
      resource :avatar, only: [:destroy]
168
      resources :milestones
Steven Thonus's avatar
Steven Thonus committed
169
    end
randx's avatar
randx committed
170 171
  end

172
  resources :projects, constraints: { id: /[^\/]+/ }, only: [:new, :create]
173

174
  devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations , passwords: :passwords, sessions: :sessions, confirmations: :confirmations }
gitlabhq's avatar
gitlabhq committed
175

176 177 178
  devise_scope :user do
    get "/users/auth/:provider/omniauth_error" => "omniauth_callbacks#omniauth_error", as: :omniauth_error
  end
179 180 181
  #
  # Project Area
  #
182
  resources :projects, constraints: { id: /[a-zA-Z.0-9_\-]+\/[a-zA-Z.0-9_\-]+/ }, except: [:new, :create, :index], path: "/" do
183 184
    member do
      put :transfer
185 186
      post :archive
      post :unarchive
187
      post :upload_image
Ciro Santilli's avatar
Ciro Santilli committed
188
      post :toggle_star
189
      get :markdown_preview
190
      get :autocomplete_sources
191 192
    end

193
    scope module: :projects do
194
      resources :blob, only: [:show, :destroy], constraints: { id: /.+/, format: false } do
skv's avatar
skv committed
195 196
        get :diff, on: :member
      end
197 198
      resources :raw,       only: [:show], constraints: {id: /.+/}
      resources :tree,      only: [:show], constraints: {id: /.+/, format: /(html|js)/ }
skv-headless's avatar
skv-headless committed
199 200 201
      resources :edit_tree, only: [:show, :update], constraints: { id: /.+/ }, path: 'edit' do
        post :preview, on: :member
      end
202 203 204 205 206
      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: /.+/}
207
      resources :network,   only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}
208 209 210 211 212
      resources :graphs,    only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/} do
        member do
          get :commits
        end
      end
213

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

216 217 218
      resources :snippets, constraints: {id: /\d+/} do
        member do
          get "raw"
219
        end
220
      end
221

222
      resources :wikis, only: [:show, :edit, :destroy, :create], constraints: {id: /[a-zA-Z.0-9_\-\/]+/} do
223 224 225 226 227
        collection do
          get :pages
          put ':id' => 'wikis#update'
          get :git_access
        end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
228

229 230 231
        member do
          get "history"
        end
Valery Sizov's avatar
Valery Sizov committed
232
      end
233

234
      resource :fork, only: [:new, :create]
235
      resource :import, only: [:new, :create, :show]
236

237
      resource :repository, only: [:show, :create] do
238
        member do
239
          get "archive", constraints: { format: Gitlab::Regex.archive_formats_regex }
240
        end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
241
      end
242

243 244 245 246
      resources :services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do
        member do
          get :test
        end
247 248
      end

249
      resources :deploy_keys, constraints: {id: /\d+/} do
250 251 252 253
        member do
          put :enable
          put :disable
        end
254 255
      end

256
      resources :branches, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
257 258
      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 }
miks's avatar
miks committed
259

260 261 262 263
      resources :refs, only: [] do
        collection do
          get "switch"
        end
gitlabhq's avatar
gitlabhq committed
264

265 266
        member do
          # tree viewer logs
267
          get "logs_tree", constraints: { id: Gitlab::Regex.git_reference_regex }
268 269 270
          get "logs_tree/:path" => "refs#logs_tree",
            as: :logs_file,
            constraints: {
271
              id:   Gitlab::Regex.git_reference_regex,
272 273 274
              path: /.*/
            }
        end
gitlabhq's avatar
gitlabhq committed
275
      end
gitlabhq's avatar
gitlabhq committed
276

277 278 279
      resources :merge_requests, constraints: {id: /\d+/}, except: [:destroy] do
        member do
          get :diffs
280
          post :automerge
281 282 283
          get :automerge_check
          get :ci_status
        end
284

285 286 287
        collection do
          get :branch_from
          get :branch_to
288
          get :update_branches
289
        end
290
      end
291

292
      resources :hooks, only: [:index, :create, :destroy], constraints: {id: /\d+/} do
293 294 295
        member do
          get :test
        end
296
      end
297

298
      resources :team, controller: 'team_members', only: [:index]
299 300 301
      resources :milestones, except: [:destroy], constraints: {id: /\d+/} do
        member do
          put :sort_issues
302
          put :sort_merge_requests
303 304
        end
      end
305

306
      resources :labels, constraints: {id: /\d+/} do
307 308 309
        collection do
          post :generate
        end
310 311
      end

312
      resources :issues, constraints: {id: /\d+/}, except: [:destroy] do
313 314 315
        collection do
          post  :bulk_update
        end
Adam Leonard's avatar
Adam Leonard committed
316
      end
Robert Speicher's avatar
Robert Speicher committed
317

318
      resources :team_members, except: [:index, :edit], constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ } do
319
        collection do
320
          delete :leave
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
321

322 323 324 325 326
          # Used for import team
          # from another project
          get :import
          post :apply_import
        end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
327 328
      end

329
      resources :notes, only: [:index, :create, :destroy, :update], constraints: {id: /\d+/} do
330
        member do
331
          delete :delete_attachment
332
        end
333
      end
334
    end
gitlabhq's avatar
gitlabhq committed
335
  end
336

337
  get ':id' => "namespaces#show", constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/}
GitLab's avatar
GitLab committed
338

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
339
  root to: "dashboard#show"
gitlabhq's avatar
gitlabhq committed
340
end