utils.go 450 B

12345678910111213141516171819
  1. // Copyright 2016 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package convert
  5. import (
  6. "gogs.io/gogs/internal/conf"
  7. )
  8. // ToCorrectPageSize makes sure page size is in allowed range.
  9. func ToCorrectPageSize(size int) int {
  10. if size <= 0 {
  11. size = 10
  12. } else if size > conf.API.MaxResponseItems {
  13. size = conf.API.MaxResponseItems
  14. }
  15. return size
  16. }