@@ -26,6 +26,7 @@ type PaginationResponse struct {
2626 NumPages int `json:"numPages"`
2727 ResultArray []interface {} `json:"resultArray"`
2828 Next * string `json:"next,omitempty"`
29+ Cursor * string `json:"cursor"`
2930}
3031
3132type PageInfo struct {
@@ -187,6 +188,8 @@ func HandleURL(w http.ResponseWriter, r *http.Request) {
187188}
188189
189190func HandleNonNumericCursor (w http.ResponseWriter , r * http.Request ) {
191+ limit := 15
192+
190193 queryCursor := r .FormValue ("cursor" )
191194 var pagination NonNumericCursorRequest
192195 hasBody := true
@@ -199,11 +202,18 @@ func HandleNonNumericCursor(w http.ResponseWriter, r *http.Request) {
199202 NumPages : 0 ,
200203 ResultArray : make ([]interface {}, 0 ),
201204 }
205+
202206 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 ++ {
204208 res .ResultArray = append (res .ResultArray , unhash (i ))
205209 }
206210
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+
207217 w .Header ().Set ("Content-Type" , "application/json" )
208218 err := json .NewEncoder (w ).Encode (res )
209219 if err != nil {
0 commit comments