Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
76e4d94d
Commit
76e4d94d
authored
Sep 03, 2012
by
Nihad Abbasov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add pagination to API
parent
6817a6a2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
5 deletions
+16
-5
doc/api/README.md
doc/api/README.md
+7
-0
lib/api/helpers.rb
lib/api/helpers.rb
+4
-0
lib/api/issues.rb
lib/api/issues.rb
+2
-2
lib/api/milestones.rb
lib/api/milestones.rb
+1
-1
lib/api/projects.rb
lib/api/projects.rb
+1
-1
lib/api/users.rb
lib/api/users.rb
+1
-1
No files found.
doc/api/README.md
View file @
76e4d94d
...
@@ -23,6 +23,13 @@ GET http://example.com/api/v2/projects?private_token=QVy1PB7sTxfy4pqfZM1U
...
@@ -23,6 +23,13 @@ GET http://example.com/api/v2/projects?private_token=QVy1PB7sTxfy4pqfZM1U
The API uses JSON to serialize data. You don't need to specify
`.json`
at the end of API URL.
The API uses JSON to serialize data. You don't need to specify
`.json`
at the end of API URL.
#### Pagination
When listing resources you can pass the following parameters:
+
`page`
(default:
`1`
) - page number
+
`per_page`
(default:
`20`
, max:
`100`
) - how many items to list per page
## Contents
## Contents
+
[
Users
](
https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/users.md
)
+
[
Users
](
https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/users.md
)
...
...
lib/api/helpers.rb
View file @
76e4d94d
...
@@ -14,6 +14,10 @@ module Gitlab
...
@@ -14,6 +14,10 @@ module Gitlab
@project
@project
end
end
def
paginate
(
object
)
object
.
page
(
params
[
:page
]).
per
(
params
[
:per_page
].
to_i
)
end
def
authenticate!
def
authenticate!
error!
({
'message'
=>
'401 Unauthorized'
},
401
)
unless
current_user
error!
({
'message'
=>
'401 Unauthorized'
},
401
)
unless
current_user
end
end
...
...
lib/api/issues.rb
View file @
76e4d94d
...
@@ -9,7 +9,7 @@ module Gitlab
...
@@ -9,7 +9,7 @@ module Gitlab
# Example Request:
# Example Request:
# GET /issues
# GET /issues
get
do
get
do
present
current_user
.
issues
,
with:
Entities
::
Issue
present
paginate
(
current_user
.
issues
)
,
with:
Entities
::
Issue
end
end
end
end
...
@@ -21,7 +21,7 @@ module Gitlab
...
@@ -21,7 +21,7 @@ module Gitlab
# Example Request:
# Example Request:
# GET /projects/:id/issues
# GET /projects/:id/issues
get
":id/issues"
do
get
":id/issues"
do
present
user_project
.
issues
,
with:
Entities
::
Issue
present
paginate
(
user_project
.
issues
)
,
with:
Entities
::
Issue
end
end
# Get a single project issue
# Get a single project issue
...
...
lib/api/milestones.rb
View file @
76e4d94d
...
@@ -11,7 +11,7 @@ module Gitlab
...
@@ -11,7 +11,7 @@ module Gitlab
# Example Request:
# Example Request:
# GET /projects/:id/milestones
# GET /projects/:id/milestones
get
":id/milestones"
do
get
":id/milestones"
do
present
user_project
.
milestones
,
with:
Entities
::
Milestone
present
paginate
(
user_project
.
milestones
)
,
with:
Entities
::
Milestone
end
end
# Get a single project milestone
# Get a single project milestone
...
...
lib/api/projects.rb
View file @
76e4d94d
...
@@ -9,7 +9,7 @@ module Gitlab
...
@@ -9,7 +9,7 @@ module Gitlab
# Example Request:
# Example Request:
# GET /projects
# GET /projects
get
do
get
do
@projects
=
current_user
.
projects
@projects
=
paginate
current_user
.
projects
present
@projects
,
with:
Entities
::
Project
present
@projects
,
with:
Entities
::
Project
end
end
...
...
lib/api/users.rb
View file @
76e4d94d
...
@@ -9,7 +9,7 @@ module Gitlab
...
@@ -9,7 +9,7 @@ module Gitlab
# Example Request:
# Example Request:
# GET /users
# GET /users
get
do
get
do
@users
=
User
.
all
@users
=
paginate
User
present
@users
,
with:
Entities
::
User
present
@users
,
with:
Entities
::
User
end
end
...
...
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