Skip to content

Commit 09ec5d0

Browse files
committed
Add undocumented endpoint for /repositories/:id
1 parent 21e8dee commit 09ec5d0

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

routers/api/v1/api.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ func RegisterRoutes(m *macaron.Macaron) {
243243
m.Get("/search", repo.Search)
244244
})
245245

246+
m.Combo("/repositories/:id", reqToken()).Get(repo.GetByID)
247+
246248
m.Group("/repos", func() {
247249
m.Post("/migrate", bind(auth.MigrateRepoForm{}), repo.Migrate)
248250
m.Combo("/:username/:reponame", context.ExtractOwnerAndRepo()).

routers/api/v1/repo/repo.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,21 @@ func Get(ctx *context.APIContext) {
251251
ctx.JSON(200, repo.APIFormat(&api.Permission{true, true, true}))
252252
}
253253

254+
// GetByID returns a single Repository
255+
func GetByID(ctx *context.APIContext) {
256+
repo, err := models.GetRepositoryByID(ctx.ParamsInt64(":id"))
257+
if err != nil {
258+
if models.IsErrRepoNotExist(err) {
259+
ctx.Status(404)
260+
} else {
261+
ctx.Error(500, "GetRepositoryByID", err)
262+
}
263+
return
264+
}
265+
266+
ctx.JSON(200, repo.APIFormat(&api.Permission{true, true, true}))
267+
}
268+
254269
// Delete delete one repository
255270
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#delete
256271
func Delete(ctx *context.APIContext) {

0 commit comments

Comments
 (0)