From b041fd962bbb3fcd79b162b42da3ec48e0eaba26 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Wed, 21 Apr 2021 14:21:20 +0700 Subject: http: add field Page to EndpointResponse The page field contains the requested page or current response. If page is from request then the offset will be set to page times limit. While at it, move the field comment to its declaration. --- lib/http/endpoint_response.go | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/http/endpoint_response.go b/lib/http/endpoint_response.go index d6808254..921464b9 100644 --- a/lib/http/endpoint_response.go +++ b/lib/http/endpoint_response.go @@ -8,21 +8,29 @@ import liberrors "github.com/shuLhan/share/lib/errors" // Its embed the lib/errors.E type to work seamlessly with Endpoint.Call // handler for checking the returned error. // -// If the response is paging, contains more than one item in data, one -// can set the current status of paging in field Offset, Limit, and Count. -// -// The Offset field contains the start index of paging. -// The Limit field contains the maximum number of records per page. -// The Count field contains the total number of records. +// If the response is paging, contains more than one item in Data, one +// can set the current status of paging in field Limit, Offset, Page, and +// Count. // // See the example below on how to use it with Endpoint.Call handler. // type EndpointResponse struct { liberrors.E - Data interface{} `json:"data,omitempty"` - Offset int64 `json:"offset,omitempty"` - Limit int64 `json:"limit,omitempty"` - Count int64 `json:"count,omitempty"` + Data interface{} `json:"data,omitempty"` + + // The Limit field contains the maximum number of records per page. + Limit int64 `json:"limit,omitempty"` + + // The Offset field contains the start index of paging. + // If Page values is from request then the offset will be set to page + // times limit. + Offset int64 `json:"offset,omitempty"` + + // The Page field contains the requested or current page of response. + Page int64 `json:"page,omitempty"` + + // Count field contains the total number of records. + Count int64 `json:"count,omitempty"` } // -- cgit v1.3