未验证 提交 c1dccd46 编写于 作者: H hongming

support querying resources without paging

Signed-off-by: Nhongming <talonwan@yunify.com>
上级 da362aff
......@@ -37,12 +37,9 @@ func ParsePaging(paging string) (limit, offset int) {
limit = 10
offset = 0
if groups := regexp.MustCompile(`^limit=(\d+),page=(\d+)$`).FindStringSubmatch(paging); len(groups) == 3 {
if groups := regexp.MustCompile(`^limit=(-?\d+),page=(\d+)$`).FindStringSubmatch(paging); len(groups) == 3 {
limit, _ = strconv.Atoi(groups[1])
page, _ := strconv.Atoi(groups[2])
if page < 0 {
page = 1
}
offset = (page - 1) * limit
}
return
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册