Skip to content

Instantly share code, notes, and snippets.

@fsamin
Created September 16, 2016 13:43
Show Gist options
  • Save fsamin/45f31d2f87caea381ef448572d5b1127 to your computer and use it in GitHub Desktop.
Save fsamin/45f31d2f87caea381ef448572d5b1127 to your computer and use it in GitHub Desktop.
func getNextPage(headers http.Header) string {
linkHeader := headers.Get("Link")
if linkHeader != "" {
links := strings.Split(linkHeader, ",")
for _, link := range links {
if strings.Contains(link, "rel=\"next\"") {
r, _ := regexp.Compile("<(.*)>.*")
s := r.FindStringSubmatch(link)
if len(s) == 2 {
return s[1]
}
break
}
}
}
return ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment