Skip to content

Commit

Permalink
add prev pagination header
Browse files Browse the repository at this point in the history
  • Loading branch information
ingride committed Feb 17, 2021
1 parent f023c23 commit 3201add
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions api/pagination.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ func addPaginationHeaders(w http.ResponseWriter, r *http.Request, p *models.Pagi
url.RawQuery = query.Encode()
header += "<" + url.String() + ">; rel=\"next\", "
}
if p.Page > 1 {
query.Set("page", fmt.Sprintf("%v", p.Page-1))
url.RawQuery = query.Encode()
header += "<" + url.String() + ">; rel=\"prev\", "
}
query.Set("page", fmt.Sprintf("%v", totalPages))
url.RawQuery = query.Encode()
header += "<" + url.String() + ">; rel=\"last\""
Expand Down

0 comments on commit 3201add

Please sign in to comment.