diff options
Diffstat (limited to 'routers/private')
-rw-r--r-- | routers/private/internal.go | 1 | ||||
-rw-r--r-- | routers/private/key.go | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/routers/private/internal.go b/routers/private/internal.go index ec2281c5c5..ee6e1274c3 100644 --- a/routers/private/internal.go +++ b/routers/private/internal.go @@ -82,6 +82,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Post("/repositories/:repoid/keys/:keyid/update", UpdateDeployKey) m.Get("/repositories/:repoid/user/:userid/checkunituser", CheckUnitUser) m.Get("/repositories/:repoid/has-keys/:keyid", HasDeployKey) + m.Get("/repositories/:repoid/keys/:keyid", GetDeployKey) m.Get("/repositories/:repoid/wiki/init", InitWiki) m.Post("/push/update", PushUpdate) m.Get("/protectedbranch/:pbid/:userid", CanUserPush) diff --git a/routers/private/key.go b/routers/private/key.go index 9cc1165780..ee22f6ac48 100644 --- a/routers/private/key.go +++ b/routers/private/key.go @@ -72,6 +72,24 @@ func GetUserByKeyID(ctx *macaron.Context) { ctx.JSON(200, user) } +//GetDeployKey chainload to models.GetDeployKey +func GetDeployKey(ctx *macaron.Context) { + repoID := ctx.ParamsInt64(":repoid") + keyID := ctx.ParamsInt64(":keyid") + dKey, err := models.GetDeployKeyByRepo(keyID, repoID) + if err != nil { + if models.IsErrDeployKeyNotExist(err) { + ctx.JSON(404, []byte("not found")) + return + } + ctx.JSON(500, map[string]interface{}{ + "err": err.Error(), + }) + return + } + ctx.JSON(200, dKey) +} + //HasDeployKey chainload to models.HasDeployKey func HasDeployKey(ctx *macaron.Context) { repoID := ctx.ParamsInt64(":repoid") |