aboutsummaryrefslogtreecommitdiff
path: root/routes/api/v1/user/app.go
diff options
context:
space:
mode:
authorunknwon <u@gogs.io>2019-08-08 23:53:43 -0700
committerunknwon <u@gogs.io>2019-08-08 23:53:43 -0700
commitc7ba519af2f2d8e79077d2776cb34f8b61556471 (patch)
tree5ca130efd9b4aa8cb51e3db992b918d3af36d9b4 /routes/api/v1/user/app.go
parent04de9778553adc376d43db21d40a6b93808c9913 (diff)
routes/api/v1: codemod
Diffstat (limited to 'routes/api/v1/user/app.go')
-rw-r--r--routes/api/v1/user/app.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/routes/api/v1/user/app.go b/routes/api/v1/user/app.go
index 09ac1909..864ede54 100644
--- a/routes/api/v1/user/app.go
+++ b/routes/api/v1/user/app.go
@@ -5,17 +5,18 @@
package user
import (
+ "net/http"
+
api "github.com/gogs/go-gogs-client"
"github.com/gogs/gogs/models"
"github.com/gogs/gogs/pkg/context"
)
-// https://github.com/gogs/go-gogs-client/wiki/Users#list-access-tokens-for-a-user
func ListAccessTokens(c *context.APIContext) {
tokens, err := models.ListAccessTokens(c.User.ID)
if err != nil {
- c.Error(500, "ListAccessTokens", err)
+ c.ServerError("ListAccessTokens", err)
return
}
@@ -23,18 +24,17 @@ func ListAccessTokens(c *context.APIContext) {
for i := range tokens {
apiTokens[i] = &api.AccessToken{tokens[i].Name, tokens[i].Sha1}
}
- c.JSON(200, &apiTokens)
+ c.JSONSuccess(&apiTokens)
}
-// https://github.com/gogs/go-gogs-client/wiki/Users#create-a-access-token
func CreateAccessToken(c *context.APIContext, form api.CreateAccessTokenOption) {
t := &models.AccessToken{
UID: c.User.ID,
Name: form.Name,
}
if err := models.NewAccessToken(t); err != nil {
- c.Error(500, "NewAccessToken", err)
+ c.ServerError("NewAccessToken", err)
return
}
- c.JSON(201, &api.AccessToken{t.Name, t.Sha1})
+ c.JSON(http.StatusCreated, &api.AccessToken{t.Name, t.Sha1})
}