diff options
author | unknwon <u@gogs.io> | 2019-08-08 23:53:43 -0700 |
---|---|---|
committer | unknwon <u@gogs.io> | 2019-08-08 23:53:43 -0700 |
commit | c7ba519af2f2d8e79077d2776cb34f8b61556471 (patch) | |
tree | 5ca130efd9b4aa8cb51e3db992b918d3af36d9b4 /routes/api/v1/user/user.go | |
parent | 04de9778553adc376d43db21d40a6b93808c9913 (diff) |
routes/api/v1: codemod
Diffstat (limited to 'routes/api/v1/user/user.go')
-rw-r--r-- | routes/api/v1/user/user.go | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/routes/api/v1/user/user.go b/routes/api/v1/user/user.go index b2af271b..9a5cbb5c 100644 --- a/routes/api/v1/user/user.go +++ b/routes/api/v1/user/user.go @@ -5,6 +5,8 @@ package user import ( + "net/http" + "github.com/Unknwon/com" api "github.com/gogs/go-gogs-client" @@ -27,7 +29,7 @@ func Search(c *context.APIContext) { users, _, err := models.SearchUserByName(opts) if err != nil { - c.JSON(500, map[string]interface{}{ + c.JSON(http.StatusInternalServerError, map[string]interface{}{ "ok": false, "error": err.Error(), }) @@ -47,7 +49,7 @@ func Search(c *context.APIContext) { } } - c.JSON(200, map[string]interface{}{ + c.JSONSuccess(map[string]interface{}{ "ok": true, "data": results, }) @@ -57,9 +59,9 @@ func GetInfo(c *context.APIContext) { u, err := models.GetUserByName(c.Params(":username")) if err != nil { if errors.IsUserNotExist(err) { - c.Status(404) + c.NotFound() } else { - c.Error(500, "GetUserByName", err) + c.ServerError("GetUserByName", err) } return } @@ -68,9 +70,9 @@ func GetInfo(c *context.APIContext) { if !c.IsLogged { u.Email = "" } - c.JSON(200, u.APIFormat()) + c.JSONSuccess(u.APIFormat()) } func GetAuthenticatedUser(c *context.APIContext) { - c.JSON(200, c.User.APIFormat()) + c.JSONSuccess(c.User.APIFormat()) } |