diff options
author | Unknwon <u@gogs.io> | 2016-07-04 17:27:06 +0800 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-07-04 17:27:06 +0800 |
commit | 4b25bdfbc45479d64e3ffb04abbd08672ccc47fb (patch) | |
tree | bbede594875a146bf4c34ce2760202cffe6aeb33 /routers/api/v1/convert/utils.go | |
parent | 528682a294834611a95b2cf6c80efdccdf6fd791 (diff) | |
download | gitea-4b25bdfbc45479d64e3ffb04abbd08672ccc47fb.tar.gz gitea-4b25bdfbc45479d64e3ffb04abbd08672ccc47fb.zip |
#3058 #3059 support correct page size and link header
Diffstat (limited to 'routers/api/v1/convert/utils.go')
-rw-r--r-- | routers/api/v1/convert/utils.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/routers/api/v1/convert/utils.go b/routers/api/v1/convert/utils.go new file mode 100644 index 0000000000..f34fb3d2b6 --- /dev/null +++ b/routers/api/v1/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 ( + "github.com/gogits/gogs/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 +} |