mirror of
https://github.com/rancher/norman.git
synced 2025-09-01 23:36:58 +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 == "" {
|
if request.ID == "" {
|
||||||
opts := parse.QueryOptions(request, request.Schema)
|
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)
|
data, err = store.List(request, request.Schema, &opts)
|
||||||
} else if request.Link == "" {
|
} else if request.Link == "" {
|
||||||
data, err = store.ByID(request, request.Schema, request.ID)
|
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 {
|
func parsePagination(apiContext *types.APIContext) *types.Pagination {
|
||||||
|
if apiContext.Pagination != nil {
|
||||||
|
return apiContext.Pagination
|
||||||
|
}
|
||||||
|
|
||||||
q := apiContext.Query
|
q := apiContext.Query
|
||||||
limit := q.Get("limit")
|
limit := q.Get("limit")
|
||||||
marker := q.Get("marker")
|
marker := q.Get("marker")
|
||||||
|
@@ -101,6 +101,7 @@ type APIContext struct {
|
|||||||
URLBuilder URLBuilder
|
URLBuilder URLBuilder
|
||||||
AccessControl AccessControl
|
AccessControl AccessControl
|
||||||
SubContext map[string]string
|
SubContext map[string]string
|
||||||
|
Pagination *Pagination
|
||||||
|
|
||||||
Request *http.Request
|
Request *http.Request
|
||||||
Response http.ResponseWriter
|
Response http.ResponseWriter
|
||||||
|
Reference in New Issue
Block a user