aboutsummaryrefslogtreecommitdiff
path: root/routes/api/v1/user/app.go
diff options
context:
space:
mode:
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})
}