@@ -26,6 +26,7 @@ type PaginationResponse struct {
26
26
NumPages int `json:"numPages"`
27
27
ResultArray []interface {} `json:"resultArray"`
28
28
Next * string `json:"next,omitempty"`
29
+ Cursor * string `json:"cursor"`
29
30
}
30
31
31
32
type PageInfo struct {
@@ -187,6 +188,8 @@ func HandleURL(w http.ResponseWriter, r *http.Request) {
187
188
}
188
189
189
190
func HandleNonNumericCursor (w http.ResponseWriter , r * http.Request ) {
191
+ limit := 15
192
+
190
193
queryCursor := r .FormValue ("cursor" )
191
194
var pagination NonNumericCursorRequest
192
195
hasBody := true
@@ -199,11 +202,18 @@ func HandleNonNumericCursor(w http.ResponseWriter, r *http.Request) {
199
202
NumPages : 0 ,
200
203
ResultArray : make ([]interface {}, 0 ),
201
204
}
205
+
202
206
var cursorI , _ = hash (cursor )
203
- for i := cursorI + 1 ; i < total && len (res .ResultArray ) < 15 ; i ++ {
207
+ for i := cursorI + 1 ; i < total && len (res .ResultArray ) < limit ; i ++ {
204
208
res .ResultArray = append (res .ResultArray , unhash (i ))
205
209
}
206
210
211
+ // output cursor to $.cursor in addition to $.resultArray[(@.length-1)]
212
+ if len (res .ResultArray ) == limit {
213
+ cursor , _ := res .ResultArray [len (res .ResultArray )- 1 ].(string )
214
+ res .Cursor = & cursor
215
+ }
216
+
207
217
w .Header ().Set ("Content-Type" , "application/json" )
208
218
err := json .NewEncoder (w ).Encode (res )
209
219
if err != nil {
0 commit comments