diff options
author | Unknwon <u@gogs.io> | 2017-06-11 00:34:14 -0400 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2017-06-11 00:34:14 -0400 |
commit | 4400d2fdd933204044aeb18ce7d8613c53aa87c0 (patch) | |
tree | 841e91d5294c49b7335170fbc4b9ff79e882f91a /routers/api/v1/user/user.go | |
parent | 6197a7639a88f7fb0fee8927e1d501504ae770ff (diff) |
Refactoring: rename package routers -> routes
Diffstat (limited to 'routers/api/v1/user/user.go')
-rw-r--r-- | routers/api/v1/user/user.go | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/routers/api/v1/user/user.go b/routers/api/v1/user/user.go deleted file mode 100644 index dbf727de..00000000 --- a/routers/api/v1/user/user.go +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2014 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package user - -import ( - "github.com/Unknwon/com" - - api "github.com/gogits/go-gogs-client" - - "github.com/gogits/gogs/models" - "github.com/gogits/gogs/models/errors" - "github.com/gogits/gogs/pkg/context" -) - -func Search(c *context.APIContext) { - opts := &models.SearchUserOptions{ - Keyword: c.Query("q"), - Type: models.USER_TYPE_INDIVIDUAL, - PageSize: com.StrTo(c.Query("limit")).MustInt(), - } - if opts.PageSize == 0 { - opts.PageSize = 10 - } - - users, _, err := models.SearchUserByName(opts) - if err != nil { - c.JSON(500, map[string]interface{}{ - "ok": false, - "error": err.Error(), - }) - return - } - - results := make([]*api.User, len(users)) - for i := range users { - results[i] = &api.User{ - ID: users[i].ID, - UserName: users[i].Name, - AvatarUrl: users[i].AvatarLink(), - FullName: users[i].FullName, - } - if c.IsLogged { - results[i].Email = users[i].Email - } - } - - c.JSON(200, map[string]interface{}{ - "ok": true, - "data": results, - }) -} - -func GetInfo(c *context.APIContext) { - u, err := models.GetUserByName(c.Params(":username")) - if err != nil { - if errors.IsUserNotExist(err) { - c.Status(404) - } else { - c.Error(500, "GetUserByName", err) - } - return - } - - // Hide user e-mail when API caller isn't signed in. - if !c.IsLogged { - u.Email = "" - } - c.JSON(200, u.APIFormat()) -} - -func GetAuthenticatedUser(c *context.APIContext) { - c.JSON(200, c.User.APIFormat()) -} |