diff options
Diffstat (limited to 'routers/api/v1/user/keys.go')
-rw-r--r-- | routers/api/v1/user/keys.go | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/routers/api/v1/user/keys.go b/routers/api/v1/user/keys.go index 213631e146..8ba73d9934 100644 --- a/routers/api/v1/user/keys.go +++ b/routers/api/v1/user/keys.go @@ -10,13 +10,12 @@ import ( "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/middleware" "github.com/gogits/gogs/modules/setting" + "github.com/gogits/gogs/routers/api/v1/convert" "github.com/gogits/gogs/routers/api/v1/repo" - to "github.com/gogits/gogs/routers/api/v1/utils" ) -// GetUserByParams returns user whose name is presented in URL paramenter. -func GetUserByParams(ctx *middleware.Context) *models.User { - user, err := models.GetUserByName(ctx.Params(":username")) +func GetUserByParamsName(ctx *middleware.Context, name string) *models.User { + user, err := models.GetUserByName(ctx.Params(name)) if err != nil { if models.IsErrUserNotExist(err) { ctx.Error(404) @@ -28,6 +27,11 @@ func GetUserByParams(ctx *middleware.Context) *models.User { return user } +// GetUserByParams returns user whose name is presented in URL paramenter. +func GetUserByParams(ctx *middleware.Context) *models.User { + return GetUserByParamsName(ctx, ":username") +} + func composePublicKeysAPILink() string { return setting.AppUrl + "api/v1/user/keys/" } @@ -42,7 +46,7 @@ func listPublicKeys(ctx *middleware.Context, uid int64) { apiLink := composePublicKeysAPILink() apiKeys := make([]*api.PublicKey, len(keys)) for i := range keys { - apiKeys[i] = to.ApiPublicKey(apiLink, keys[i]) + apiKeys[i] = convert.ToApiPublicKey(apiLink, keys[i]) } ctx.JSON(200, &apiKeys) @@ -75,7 +79,7 @@ func GetPublicKey(ctx *middleware.Context) { } apiLink := composePublicKeysAPILink() - ctx.JSON(200, to.ApiPublicKey(apiLink, key)) + ctx.JSON(200, convert.ToApiPublicKey(apiLink, key)) } // CreateUserPublicKey creates new public key to given user by ID. @@ -92,7 +96,7 @@ func CreateUserPublicKey(ctx *middleware.Context, form api.CreateKeyOption, uid return } apiLink := composePublicKeysAPILink() - ctx.JSON(201, to.ApiPublicKey(apiLink, key)) + ctx.JSON(201, convert.ToApiPublicKey(apiLink, key)) } // https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#create-a-public-key |