mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-02-01 20:22:21 +00:00
29 lines
508 B
Go
29 lines
508 B
Go
|
package session
|
||
|
|
||
|
import (
|
||
|
"strconv"
|
||
|
|
||
|
"github.com/gin-gonic/gin"
|
||
|
"github.com/woodpecker-ci/woodpecker/server/model"
|
||
|
)
|
||
|
|
||
|
const (
|
||
|
defaultPage = 1
|
||
|
defaultPerPage = 25
|
||
|
)
|
||
|
|
||
|
func Pagination(c *gin.Context) *model.PaginationData {
|
||
|
page, err := strconv.ParseInt(c.Param("page"), 10, 64)
|
||
|
if err != nil {
|
||
|
page = defaultPage
|
||
|
}
|
||
|
perPage, err := strconv.ParseInt(c.Param("perPage"), 10, 64)
|
||
|
if err != nil {
|
||
|
perPage = defaultPerPage
|
||
|
}
|
||
|
return &model.PaginationData{
|
||
|
Page: page,
|
||
|
PerPage: perPage,
|
||
|
}
|
||
|
}
|