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:
@@ -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)
|
||||
|
@@ -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")
|
||||
|
@@ -101,6 +101,7 @@ type APIContext struct {
|
||||
URLBuilder URLBuilder
|
||||
AccessControl AccessControl
|
||||
SubContext map[string]string
|
||||
Pagination *Pagination
|
||||
|
||||
Request *http.Request
|
||||
Response http.ResponseWriter
|
||||
|
Reference in New Issue
Block a user