|
@@ -9,22 +9,22 @@ For the moment, *depager* only supports JSON responses.
|
|
|
interfaces:
|
|
|
|
|
|
```go
|
|
|
-/* The `Page` interface must wrap server responses. This
|
|
|
-* allows pagers to calculate page sizes and iterate over
|
|
|
-* response aggregates.
|
|
|
-*
|
|
|
-* The underlying implementation must be a pointer to a
|
|
|
-* struct containing the desired response fields, all tagged
|
|
|
-* appropriately. Any fields corresponding to
|
|
|
-* platform-specific error responses should also be
|
|
|
-* included.
|
|
|
-*
|
|
|
-* `Count()` must return the total number of items to be
|
|
|
-* paged. `Elems()` must return the items from the current
|
|
|
-* page.
|
|
|
+/*
|
|
|
+The `Page` interface must wrap server responses. This
|
|
|
+allows pagers to calculate page sizes and iterate over
|
|
|
+response aggregates.
|
|
|
+
|
|
|
+The underlying implementation must be a pointer to a
|
|
|
+struct containing the desired response fields, all tagged
|
|
|
+appropriately. Any fields corresponding to
|
|
|
+platform-specific error responses should also be
|
|
|
+included.
|
|
|
*/
|
|
|
type Page[T any] interface {
|
|
|
+ // Count must return the total number of items to be paged
|
|
|
Count() uint64
|
|
|
+
|
|
|
+ // Elems must return the items from the current page
|
|
|
Elems() []T
|
|
|
}
|
|
|
|
|
@@ -59,9 +59,10 @@ type pagedURI struct {
|
|
|
}
|
|
|
|
|
|
func (u pagedURI) PageURI(limit, offset uint64) url.URL {
|
|
|
- /* Different APIs use different conventions. Simply map
|
|
|
- * limit and offset to the apposite field names with
|
|
|
- * whatever semantics the server expects.
|
|
|
+ /*
|
|
|
+ Different APIs use different conventions. Simply map
|
|
|
+ limit and offset to the apposite field names with
|
|
|
+ whatever semantics the server expects.
|
|
|
*/
|
|
|
if limit > MaxPageSize {
|
|
|
limit = MaxPageSize
|
|
@@ -106,9 +107,10 @@ func makeMyPager[T any](
|
|
|
)
|
|
|
}
|
|
|
|
|
|
-/* .
|
|
|
-* .
|
|
|
-* .
|
|
|
+/*
|
|
|
+.
|
|
|
+.
|
|
|
+.
|
|
|
*/
|
|
|
|
|
|
type Thing struct {
|