@@ -23,13 +23,9 @@ type NonNumericCursorRequest struct {
23
23
}
24
24
25
25
type PaginationResponse struct {
26
- << << << < HEAD
27
- NumPages int `json:"numPages"`
28
- ResultArray []int `json:"resultArray"`
29
- Next * string `json:"next,omitempty"`
30
- == == == =
31
26
NumPages int `json:"numPages"`
32
27
ResultArray []interface {} `json:"resultArray"`
28
+ Next * string `json:"next,omitempty"`
33
29
}
34
30
35
31
// Insecure reversable hashing for string cursors
@@ -38,7 +34,6 @@ func hash(s string) (int, error) {
38
34
}
39
35
func unhash (h int ) string {
40
36
return strconv .Itoa (h )
41
- >> >> >> > cf9ad59 (add endpoint to support non numeric cursor .)
42
37
}
43
38
44
39
const total = 20
@@ -151,7 +146,7 @@ func HandleURL(w http.ResponseWriter, r *http.Request) {
151
146
152
147
res := PaginationResponse {
153
148
NumPages : 0 ,
154
- ResultArray : make ([]int , 0 ),
149
+ ResultArray : make ([]interface {} , 0 ),
155
150
}
156
151
157
152
if attempts > 1 {
@@ -184,7 +179,6 @@ func HandleNonNumericCursor(w http.ResponseWriter, r *http.Request) {
184
179
if err := json .NewDecoder (r .Body ).Decode (& pagination ); err != nil {
185
180
hasBody = false
186
181
}
187
-
188
182
cursor := getNonNumericValue (queryCursor , hasBody , pagination .Cursor )
189
183
190
184
res := PaginationResponse {
@@ -219,6 +213,10 @@ func getNonNumericValue(queryValue string, hasBody bool, paginationValue string)
219
213
if hasBody {
220
214
return paginationValue
221
215
} else {
222
- return queryValue
216
+ if queryValue == "" {
217
+ return "-1"
218
+ } else {
219
+ return queryValue
220
+ }
223
221
}
224
222
}
0 commit comments