Browse Source

Add undocumented endpoint for /repositories/:id

pull/3742/head
Kim "BKC" Carlbäcker 8 years ago
parent
commit
3367af7b2f
  1. 2
      routers/api/v1/api.go
  2. 14
      routers/api/v1/repo/repo.go

2
routers/api/v1/api.go

@ -232,6 +232,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").Get(repo.Get).

14
routers/api/v1/repo/repo.go

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

Loading…
Cancel
Save