You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

api.go 966B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright 2023 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package setting
  4. import (
  5. "net/url"
  6. "path"
  7. "code.gitea.io/gitea/modules/log"
  8. )
  9. // API settings
  10. var API = struct {
  11. EnableSwagger bool
  12. SwaggerURL string
  13. MaxResponseItems int
  14. DefaultPagingNum int
  15. DefaultGitTreesPerPage int
  16. DefaultMaxBlobSize int64
  17. }{
  18. EnableSwagger: true,
  19. SwaggerURL: "",
  20. MaxResponseItems: 50,
  21. DefaultPagingNum: 30,
  22. DefaultGitTreesPerPage: 1000,
  23. DefaultMaxBlobSize: 10485760,
  24. }
  25. func loadAPIFrom(rootCfg ConfigProvider) {
  26. mustMapSetting(rootCfg, "api", &API)
  27. defaultAppURL := string(Protocol) + "://" + Domain + ":" + HTTPPort
  28. u, err := url.Parse(rootCfg.Section("server").Key("ROOT_URL").MustString(defaultAppURL))
  29. if err != nil {
  30. log.Fatal("Invalid ROOT_URL '%s': %s", AppURL, err)
  31. }
  32. u.Path = path.Join(u.Path, "api", "swagger")
  33. API.SwaggerURL = u.String()
  34. }