aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1/user/key.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2016-11-24 15:04:31 +0800
committerGitHub <noreply@github.com>2016-11-24 15:04:31 +0800
commit3917ed45de063b4e8868610c82d8172020d572fd (patch)
tree052b7651cbb64ae30f92efe87441ad1d4fa2d922 /routers/api/v1/user/key.go
parent3a3782bb7fed768c1e832ff4c0a77f2f5281ed05 (diff)
downloadgitea-3917ed45de063b4e8868610c82d8172020d572fd.tar.gz
gitea-3917ed45de063b4e8868610c82d8172020d572fd.zip
golint fixed for routers (#208)
Diffstat (limited to 'routers/api/v1/user/key.go')
-rw-r--r--routers/api/v1/user/key.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/routers/api/v1/user/key.go b/routers/api/v1/user/key.go
index 6df405a16c..c743b5deab 100644
--- a/routers/api/v1/user/key.go
+++ b/routers/api/v1/user/key.go
@@ -14,6 +14,7 @@ import (
"code.gitea.io/gitea/routers/api/v1/repo"
)
+// GetUserByParamsName get user by name
func GetUserByParamsName(ctx *context.APIContext, name string) *models.User {
user, err := models.GetUserByName(ctx.Params(name))
if err != nil {
@@ -52,12 +53,14 @@ func listPublicKeys(ctx *context.APIContext, uid int64) {
ctx.JSON(200, &apiKeys)
}
-// https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#list-your-public-keys
+// ListMyPublicKeys list all my public keys
+// see https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#list-your-public-keys
func ListMyPublicKeys(ctx *context.APIContext) {
listPublicKeys(ctx, ctx.User.ID)
}
-// https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#list-public-keys-for-a-user
+// ListPublicKeys list all user's public keys
+// see https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#list-public-keys-for-a-user
func ListPublicKeys(ctx *context.APIContext) {
user := GetUserByParams(ctx)
if ctx.Written() {
@@ -66,7 +69,8 @@ func ListPublicKeys(ctx *context.APIContext) {
listPublicKeys(ctx, user.ID)
}
-// https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#get-a-single-public-key
+// GetPublicKey get one public key
+// see https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#get-a-single-public-key
func GetPublicKey(ctx *context.APIContext) {
key, err := models.GetPublicKeyByID(ctx.ParamsInt64(":id"))
if err != nil {
@@ -99,12 +103,14 @@ func CreateUserPublicKey(ctx *context.APIContext, form api.CreateKeyOption, uid
ctx.JSON(201, convert.ToPublicKey(apiLink, key))
}
-// https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#create-a-public-key
+// CreatePublicKey create one public key for me
+// see https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#create-a-public-key
func CreatePublicKey(ctx *context.APIContext, form api.CreateKeyOption) {
CreateUserPublicKey(ctx, form, ctx.User.ID)
}
-// https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#delete-a-public-key
+// DeletePublicKey delete one public key of mine
+// see https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#delete-a-public-key
func DeletePublicKey(ctx *context.APIContext) {
if err := models.DeletePublicKey(ctx.User, ctx.ParamsInt64(":id")); err != nil {
if models.IsErrKeyAccessDenied(err) {