Skip to content

Commit

Permalink
Fix pagination
Browse files Browse the repository at this point in the history
Problem:
Pagination is not showing up

Solution:
Pagination was being created properly but then dropped in favor of an
empty version. Save the pagination on the context so it can be accessed
later and not reset.
  • Loading branch information
dramich authored and Denise committed Jun 25, 2018
1 parent 388faeb commit aecae32
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api/handler/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ func ListHandler(request *types.APIContext, next types.RequestHandler) error {

if request.ID == "" {
opts := parse.QueryOptions(request, request.Schema)
// Save the pagination on the context so it's not reset later
request.Pagination = opts.Pagination
data, err = store.List(request, request.Schema, &opts)
} else if request.Link == "" {
data, err = store.ByID(request, request.Schema, request.ID)
Expand Down
4 changes: 4 additions & 0 deletions parse/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ func parseSort(schema *types.Schema, apiContext *types.APIContext) types.Sort {
}

func parsePagination(apiContext *types.APIContext) *types.Pagination {
if apiContext.Pagination != nil {
return apiContext.Pagination
}

q := apiContext.Query
limit := q.Get("limit")
marker := q.Get("marker")
Expand Down
1 change: 1 addition & 0 deletions types/server_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ type APIContext struct {
URLBuilder URLBuilder
AccessControl AccessControl
SubContext map[string]string
Pagination *Pagination

Request *http.Request
Response http.ResponseWriter
Expand Down

0 comments on commit aecae32

Please sign in to comment.