Skip to content

Commit 21ac6ca

Browse files
committed
chore: Return more interesting /pagination/url results
```console $ curl -XGET 'http://localhost:8080/pagination/url?attempts=3' {"numPages":0,"resultArray":[0,1,2,3,4,5,6,7,8],"next":"http://localhost:8080/pagination/url?attempts=2"} $ curl -XGET 'http://localhost:8080/pagination/url?attempts=2' {"numPages":0,"resultArray":[0,1,2,3,4,5],"next":"http://localhost:8080/pagination/url?attempts=1"} $ curl -XGET 'http://localhost:8080/pagination/url?attempts=1' {"numPages":0,"resultArray":[0,1,2]} $ curl -XGET 'http://localhost:8080/pagination/url?attempts=0' {"numPages":0,"resultArray":[]} ```
1 parent b224f69 commit 21ac6ca

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

internal/pagination/service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ func HandleURL(w http.ResponseWriter, r *http.Request) {
158158
ResultArray: make([]interface{}, 0),
159159
}
160160

161-
// Just always return the same 20 results
162-
for i := 0; i < total; i++ {
161+
// Return 9, 6, then 3 results for 18 total results.
162+
for i := 0; i < total && len(res.ResultArray) < (attempts*3); i++ {
163163
res.ResultArray = append(res.ResultArray, i)
164164
}
165165

0 commit comments

Comments
 (0)