diff options
author | Unknwon <joe2010xtmf@163.com> | 2014-11-14 17:11:30 -0500 |
---|---|---|
committer | Unknwon <joe2010xtmf@163.com> | 2014-11-14 17:11:30 -0500 |
commit | 52d66ba6c8b44b4aa28bdc2cd50acba9e22b3e66 (patch) | |
tree | a556e4e5241ccf86787097c5f4cb8767fcf06830 /modules/middleware/repo.go | |
parent | 437dd5272f557ffa3367a70230feeb1aa448b0e4 (diff) | |
download | gitea-52d66ba6c8b44b4aa28bdc2cd50acba9e22b3e66.tar.gz gitea-52d66ba6c8b44b4aa28bdc2cd50acba9e22b3e66.zip |
#12, use go-gogs-client
Diffstat (limited to 'modules/middleware/repo.go')
-rw-r--r-- | modules/middleware/repo.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index eb1aa128ae..d01f93fa4c 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -13,12 +13,12 @@ import ( "github.com/Unknwon/macaron" "github.com/gogits/gogs/models" + "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/git" "github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/modules/setting" ) -// FIXME: response error in JSON. func ApiRepoAssignment() macaron.Handler { return func(ctx *Context) { userName := ctx.Params(":username") @@ -33,7 +33,7 @@ func ApiRepoAssignment() macaron.Handler { if ctx.IsSigned { ctx.Repo.IsOwner, err = models.HasAccess(ctx.User.Name, userName+"/"+repoName, models.WRITABLE) if err != nil { - ctx.Handle(500, "HasAccess", err) + ctx.JSON(500, &base.ApiJsonErr{"HasAccess: " + err.Error(), base.DOC_URL}) return } ctx.Repo.IsTrueOwner = ctx.User.LowerName == strings.ToLower(userName) @@ -45,7 +45,7 @@ func ApiRepoAssignment() macaron.Handler { if err == models.ErrUserNotExist { ctx.Error(404) } else { - ctx.Handle(500, "GetUserByName", err) + ctx.JSON(500, &base.ApiJsonErr{"GetUserByName: " + err.Error(), base.DOC_URL}) } return } @@ -66,10 +66,10 @@ func ApiRepoAssignment() macaron.Handler { ctx.Error(404) return } - ctx.Handle(500, "GetRepositoryByName", err) + ctx.JSON(500, &base.ApiJsonErr{"GetRepositoryByName: " + err.Error(), base.DOC_URL}) return } else if err = repo.GetOwner(); err != nil { - ctx.Handle(500, "GetOwner", err) + ctx.JSON(500, &base.ApiJsonErr{"GetOwner: " + err.Error(), base.DOC_URL}) return } @@ -82,7 +82,7 @@ func ApiRepoAssignment() macaron.Handler { if u.IsOrganization() { auth, err := models.GetHighestAuthorize(u.Id, ctx.User.Id, repo.Id, 0) if err != nil { - ctx.Handle(500, "GetHighestAuthorize", err) + ctx.JSON(500, &base.ApiJsonErr{"GetHighestAuthorize: " + err.Error(), base.DOC_URL}) return } if auth == models.ORG_ADMIN { @@ -101,7 +101,7 @@ func ApiRepoAssignment() macaron.Handler { hasAccess, err := models.HasAccess(ctx.User.Name, ctx.Repo.Owner.Name+"/"+repo.Name, models.READABLE) if err != nil { - ctx.Handle(500, "HasAccess", err) + ctx.JSON(500, &base.ApiJsonErr{"HasAccess: " + err.Error(), base.DOC_URL}) return } else if !hasAccess { ctx.Error(404) |