summaryrefslogtreecommitdiffstats
path: root/routers/repo/topic.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2021-04-05 17:30:52 +0200
committerGitHub <noreply@github.com>2021-04-05 11:30:52 -0400
commit16dea6cebd375fc274fc7a9c216dbcc9e22bd5c7 (patch)
tree75d47012e9899ca24408aeef7fa3adfcd4beaed1 /routers/repo/topic.go
parente9fba18a26c9d0f8586254a83ef7afcd293a725a (diff)
downloadgitea-16dea6cebd375fc274fc7a9c216dbcc9e22bd5c7.tar.gz
gitea-16dea6cebd375fc274fc7a9c216dbcc9e22bd5c7.zip
[refactor] replace int with httpStatusCodes (#15282)
* replace "200" (int) with "http.StatusOK" (const) * ctx.Error & ctx.HTML * ctx.JSON Part1 * ctx.JSON Part2 * ctx.JSON Part3
Diffstat (limited to 'routers/repo/topic.go')
-rw-r--r--routers/repo/topic.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/routers/repo/topic.go b/routers/repo/topic.go
index b23023ceba..1d99b65094 100644
--- a/routers/repo/topic.go
+++ b/routers/repo/topic.go
@@ -5,6 +5,7 @@
package repo
import (
+ "net/http"
"strings"
"code.gitea.io/gitea/models"
@@ -15,7 +16,7 @@ import (
// TopicsPost response for creating repository
func TopicsPost(ctx *context.Context) {
if ctx.User == nil {
- ctx.JSON(403, map[string]interface{}{
+ ctx.JSON(http.StatusForbidden, map[string]interface{}{
"message": "Only owners could change the topics.",
})
return
@@ -30,7 +31,7 @@ func TopicsPost(ctx *context.Context) {
validTopics, invalidTopics := models.SanitizeAndValidateTopics(topics)
if len(validTopics) > 25 {
- ctx.JSON(422, map[string]interface{}{
+ ctx.JSON(http.StatusUnprocessableEntity, map[string]interface{}{
"invalidTopics": nil,
"message": ctx.Tr("repo.topic.count_prompt"),
})
@@ -38,7 +39,7 @@ func TopicsPost(ctx *context.Context) {
}
if len(invalidTopics) > 0 {
- ctx.JSON(422, map[string]interface{}{
+ ctx.JSON(http.StatusUnprocessableEntity, map[string]interface{}{
"invalidTopics": invalidTopics,
"message": ctx.Tr("repo.topic.format_prompt"),
})
@@ -48,13 +49,13 @@ func TopicsPost(ctx *context.Context) {
err := models.SaveTopics(ctx.Repo.Repository.ID, validTopics...)
if err != nil {
log.Error("SaveTopics failed: %v", err)
- ctx.JSON(500, map[string]interface{}{
+ ctx.JSON(http.StatusInternalServerError, map[string]interface{}{
"message": "Save topics failed.",
})
return
}
- ctx.JSON(200, map[string]interface{}{
+ ctx.JSON(http.StatusOK, map[string]interface{}{
"status": "ok",
})
}