Limit and Offset params for commits

This commit is contained in:
Kirill Zaitsev
2015-02-13 23:37:21 +03:00
parent bd8dcf8de5
commit 8d6a233744
7 changed files with 142 additions and 19 deletions

View File

@@ -16,13 +16,15 @@ import (
// GetCommitList accepts a request to retrieve a list
// of recent commits by Repo, and retur in JSON format.
//
// GET /api/repos/:host/:owner/:name/commits
// GET /api/repos/:host/:owner/:name/commits?limit=:limit&offset=:offset
//
func GetCommitList(c web.C, w http.ResponseWriter, r *http.Request) {
var ctx = context.FromC(c)
var repo = ToRepo(c)
var limit = ToLimit(r)
var offset = ToOffset(r)
commits, err := datastore.GetCommitList(ctx, repo)
commits, err := datastore.GetCommitList(ctx, repo, limit, offset)
if err != nil {
w.WriteHeader(http.StatusNotFound)
return