Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add total count & link header for pagination #393

Merged
merged 6 commits into from
Nov 22, 2022

Conversation

FreddyDevelop
Copy link
Contributor

Description

Adds the Link and X-Total-Count header to list audit logs and list users. The X-Total-Count header returns the total count of the requested resource. The Link header returns urls which can be used for pagination.

E.g. there are 155 registered users and the user list is requested with ?page=5&per_page=10, then

  • the X-Total-Count header returns 155
  • the Link header returns <http://localhost:8001/users?page=1&per_page=10>; rel="first",<http://localhost:8001/users?page=16&per_page=10>; rel="last",<http://localhost:8001/users?page=6&per_page=10>; rel="next",<http://localhost:8001/users?page=4&per_page=10>; rel="prev"

Tests

To test this just use the admin audit_log and admin users api and look into the returned headers.

Additional context

https://docs.github.com/en/rest/guides/traversing-with-pagination

@FreddyDevelop FreddyDevelop marked this pull request as ready for review November 17, 2022 14:21
@FreddyDevelop FreddyDevelop merged commit 2f9a88c into main Nov 22, 2022
@FreddyDevelop FreddyDevelop deleted the feat-add-pagination-header branch November 22, 2022 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants