Add undocumented endpoint for /repositories/:id

This commit is contained in:
Kim "BKC" Carlbäcker 2016-10-03 12:35:42 +02:00
parent bea9d55da6
commit 71bb6df75a
2 changed files with 17 additions and 0 deletions

View File

@ -243,6 +243,8 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get("/search", repo.Search) m.Get("/search", repo.Search)
}) })
m.Combo("/repositories/:id", reqToken()).Get(repo.GetByID)
m.Group("/repos", func() { m.Group("/repos", func() {
m.Post("/migrate", bind(auth.MigrateRepoForm{}), repo.Migrate) m.Post("/migrate", bind(auth.MigrateRepoForm{}), repo.Migrate)
m.Combo("/:username/:reponame", context.ExtractOwnerAndRepo()). m.Combo("/:username/:reponame", context.ExtractOwnerAndRepo()).

View File

@ -251,6 +251,21 @@ func Get(ctx *context.APIContext) {
ctx.JSON(200, repo.APIFormat(&api.Permission{true, true, true})) 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 // Delete delete one repository
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#delete // see https://github.com/gogits/go-gogs-client/wiki/Repositories#delete
func Delete(ctx *context.APIContext) { func Delete(ctx *context.APIContext) {