Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
go-gitlab
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
go-gitlab
Commits
b12c146d
Commit
b12c146d
authored
Feb 21, 2018
by
Sander van Harmelen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use constants for the pagination headers
Thanks @Lorac
😉
parent
d760a66e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
gitlab.go
gitlab.go
+15
-6
No files found.
gitlab.go
View file @
b12c146d
...
...
@@ -506,25 +506,34 @@ func newResponse(r *http.Response) *Response {
return
response
}
const
(
xTotal
=
"X-Total"
xTotalPages
=
"X-Total-Pages"
xPerPage
=
"X-Per-Page"
xPage
=
"X-Page"
xNextPage
=
"X-Next-Page"
xPrevPage
=
"X-Prev-Page"
)
// populatePageValues parses the HTTP Link response headers and populates the
// various pagination link values in the Response.
func
(
r
*
Response
)
populatePageValues
()
{
if
totalItems
:=
r
.
Response
.
Header
.
Get
(
"X-Total"
);
totalItems
!=
""
{
if
totalItems
:=
r
.
Response
.
Header
.
Get
(
xTotal
);
totalItems
!=
""
{
r
.
TotalItems
,
_
=
strconv
.
Atoi
(
totalItems
)
}
if
totalPages
:=
r
.
Response
.
Header
.
Get
(
"X-Total-Pages"
);
totalPages
!=
""
{
if
totalPages
:=
r
.
Response
.
Header
.
Get
(
xTotalPages
);
totalPages
!=
""
{
r
.
TotalPages
,
_
=
strconv
.
Atoi
(
totalPages
)
}
if
itemsPerPage
:=
r
.
Response
.
Header
.
Get
(
"X-Per-Page"
);
itemsPerPage
!=
""
{
if
itemsPerPage
:=
r
.
Response
.
Header
.
Get
(
xPerPage
);
itemsPerPage
!=
""
{
r
.
ItemsPerPage
,
_
=
strconv
.
Atoi
(
itemsPerPage
)
}
if
currentPage
:=
r
.
Response
.
Header
.
Get
(
"X-Page"
);
currentPage
!=
""
{
if
currentPage
:=
r
.
Response
.
Header
.
Get
(
xPage
);
currentPage
!=
""
{
r
.
CurrentPage
,
_
=
strconv
.
Atoi
(
currentPage
)
}
if
nextPage
:=
r
.
Response
.
Header
.
Get
(
"X-Next-Page"
);
nextPage
!=
""
{
if
nextPage
:=
r
.
Response
.
Header
.
Get
(
xNextPage
);
nextPage
!=
""
{
r
.
NextPage
,
_
=
strconv
.
Atoi
(
nextPage
)
}
if
previousPage
:=
r
.
Response
.
Header
.
Get
(
"X-Prev-Page"
);
previousPage
!=
""
{
if
previousPage
:=
r
.
Response
.
Header
.
Get
(
xPrevPage
);
previousPage
!=
""
{
r
.
PreviousPage
,
_
=
strconv
.
Atoi
(
previousPage
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment