diff options
author | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2016-10-03 12:35:42 +0200 |
---|---|---|
committer | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2016-12-02 09:18:15 +0100 |
commit | 71bb6df75ae541687c64f5e6e4da16ea9e95acfe (patch) | |
tree | a2416c56581ad7bf0c8c58013dcb014716eae956 | |
parent | bea9d55da6df19777b00213e7b5303237910e97c (diff) | |
download | gitea-71bb6df75ae541687c64f5e6e4da16ea9e95acfe.tar.gz gitea-71bb6df75ae541687c64f5e6e4da16ea9e95acfe.zip |
Add undocumented endpoint for /repositories/:id
-rw-r--r-- | routers/api/v1/api.go | 2 | ||||
-rw-r--r-- | routers/api/v1/repo/repo.go | 15 |
2 files changed, 17 insertions, 0 deletions
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 95bdfd072e..506a615624 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -243,6 +243,8 @@ func RegisterRoutes(m *macaron.Macaron) { m.Get("/search", repo.Search) }) + m.Combo("/repositories/:id", reqToken()).Get(repo.GetByID) + m.Group("/repos", func() { m.Post("/migrate", bind(auth.MigrateRepoForm{}), repo.Migrate) m.Combo("/:username/:reponame", context.ExtractOwnerAndRepo()). diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 1fa0b14b40..33d474ebd8 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -251,6 +251,21 @@ func Get(ctx *context.APIContext) { ctx.JSON(200, repo.APIFormat(&api.Permission{true, true, true})) } +// GetByID returns a single Repository +func GetByID(ctx *context.APIContext) { + repo, err := models.GetRepositoryByID(ctx.ParamsInt64(":id")) + if err != nil { + if models.IsErrRepoNotExist(err) { + ctx.Status(404) + } else { + ctx.Error(500, "GetRepositoryByID", err) + } + return + } + + ctx.JSON(200, repo.APIFormat(&api.Permission{true, true, true})) +} + // Delete delete one repository // see https://github.com/gogits/go-gogs-client/wiki/Repositories#delete func Delete(ctx *context.APIContext) { |