I want to make a request in Go
to an API but the answers are paged so I have to go through them.
The pagination comes on the header
in the element link
, something like this:
<page=3>; rel="next",<page=1>; rel="prev";<page=5>; rel="last"
I was trying to solve it with regular expressions and with Splits
but in both cases I did not succeed.
The request I'm doing with the http library, like this:
resp, err := http.Get("http://example.com/")
and the Header.link
I get it like this:
resp.Header.Get("link")
and the result is the string that I put above.
Question
How do I get the last page? And the others?
In the javascript world we have parse-link-header so maybe there is something similar in Go
.