aboutsummaryrefslogtreecommitdiffstats
path: root/modules/convert/utils.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-11-10 12:41:51 +0800
committerGitHub <noreply@github.com>2019-11-10 12:41:51 +0800
commitdaab2451676b1a3a5312af0e2a443e6017113702 (patch)
treeb0ee4405a3b9459051537e3e258fd0fafe9100b7 /modules/convert/utils.go
parent1b7402bd1dfcf7435c2c2345aab1c43d6b0186ca (diff)
downloadgitea-daab2451676b1a3a5312af0e2a443e6017113702.tar.gz
gitea-daab2451676b1a3a5312af0e2a443e6017113702.zip
Move code.gitea.io/gitea/routers/api/v1/convert to code.gitea.io/gitea/modules/convert (#8892)
* Move code.gitea.io/gitea/routers/api/v1/convert to code.gitea.io/gitea/modules/convert * fix fmt
Diffstat (limited to 'modules/convert/utils.go')
-rw-r--r--modules/convert/utils.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/modules/convert/utils.go b/modules/convert/utils.go
new file mode 100644
index 0000000000..66fb21be67
--- /dev/null
+++ b/modules/convert/utils.go
@@ -0,0 +1,19 @@
+// Copyright 2016 The Gogs Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package convert
+
+import (
+ "code.gitea.io/gitea/modules/setting"
+)
+
+// ToCorrectPageSize makes sure page size is in allowed range.
+func ToCorrectPageSize(size int) int {
+ if size <= 0 {
+ size = 10
+ } else if size > setting.API.MaxResponseItems {
+ size = setting.API.MaxResponseItems
+ }
+ return size
+}