Skip to content

Commit

Permalink
Use PaginatorPageKey and PaginatorPerPageKey variables (#615)
Browse files Browse the repository at this point in the history
* update pagination_test
  • Loading branch information
bhb603 committed Feb 6, 2021
1 parent ad18e4d commit e314840
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pagination_test.go
Expand Up @@ -31,12 +31,12 @@ func Test_NewPaginatorFromParams(t *testing.T) {
a.Equal(p.Page, 1)
a.Equal(p.PerPage, 20)

params.Set("page", "2")
params.Set(PaginatorPageKey, "2")
p = NewPaginatorFromParams(params)
a.Equal(p.Page, 2)
a.Equal(p.PerPage, 20)

params.Set("per_page", "30")
params.Set(PaginatorPerPageKey, "30")
p = NewPaginatorFromParams(params)
a.Equal(p.Page, 2)
a.Equal(p.PerPage, 30)
Expand Down
4 changes: 2 additions & 2 deletions paginator.go
Expand Up @@ -75,9 +75,9 @@ type PaginationParams interface {
// `PaginatorPerPageKey`. Defaults are `1` for the page and
// PaginatorPerPageDefault for the per page value.
func NewPaginatorFromParams(params PaginationParams) *Paginator {
page := defaults.String(params.Get("page"), "1")
page := defaults.String(params.Get(PaginatorPageKey), "1")

perPage := defaults.String(params.Get("per_page"), strconv.Itoa(PaginatorPerPageDefault))
perPage := defaults.String(params.Get(PaginatorPerPageKey), strconv.Itoa(PaginatorPerPageDefault))

p, err := strconv.Atoi(page)
if err != nil {
Expand Down

0 comments on commit e314840

Please sign in to comment.