1
0
mirror of https://github.com/rancher/norman.git synced 2025-08-31 14:51:57 +00:00

Fix pagination

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.
This commit is contained in:
Dan Ramich
2018-06-21 11:20:19 -07:00
committed by Denise
parent 388faeb89e
commit aecae32b4a
3 changed files with 7 additions and 0 deletions

View File

@@ -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)

View File

@@ -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")

View File

@@ -101,6 +101,7 @@ type APIContext struct {
URLBuilder URLBuilder
AccessControl AccessControl
SubContext map[string]string
Pagination *Pagination
Request *http.Request
Response http.ResponseWriter