Skip to content

Commit

Permalink
chore: Return more interesting /pagination/url results
Browse files Browse the repository at this point in the history
```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":[]}
```
  • Loading branch information
bflad committed Jul 22, 2024
1 parent b224f69 commit 21ac6ca
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/pagination/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ func HandleURL(w http.ResponseWriter, r *http.Request) {
ResultArray: make([]interface{}, 0),
}

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

Expand Down

0 comments on commit 21ac6ca

Please sign in to comment.