Skip to content

Commit 056c100

Browse files
committed
Use status code constants.
1 parent 1c5c318 commit 056c100

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

routers/private/hook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,5 +583,5 @@ func SetDefaultBranch(ctx *gitea_context.PrivateContext) {
583583
})
584584
return
585585
}
586-
ctx.PlainText(200, []byte("success"))
586+
ctx.PlainText(http.StatusOK, []byte("success"))
587587
}

routers/private/key.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func UpdatePublicKeyInRepo(ctx *context.PrivateContext) {
2727
deployKey, err := models.GetDeployKeyByRepo(keyID, repoID)
2828
if err != nil {
2929
if models.IsErrDeployKeyNotExist(err) {
30-
ctx.PlainText(200, []byte("success"))
30+
ctx.PlainText(http.StatusOK, []byte("success"))
3131
return
3232
}
3333
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{

routers/private/restore_repo.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package private
66

77
import (
88
"io/ioutil"
9+
"net/http"
910

1011
myCtx "code.gitea.io/gitea/modules/context"
1112
"code.gitea.io/gitea/modules/migrations"
@@ -17,7 +18,7 @@ func RestoreRepo(ctx *myCtx.PrivateContext) {
1718
json := jsoniter.ConfigCompatibleWithStandardLibrary
1819
bs, err := ioutil.ReadAll(ctx.Req.Body)
1920
if err != nil {
20-
ctx.JSON(500, map[string]string{
21+
ctx.JSON(http.StatusInternalServerError, map[string]string{
2122
"err": err.Error(),
2223
})
2324
return
@@ -29,7 +30,7 @@ func RestoreRepo(ctx *myCtx.PrivateContext) {
2930
Units []string
3031
}{}
3132
if err = json.Unmarshal(bs, &params); err != nil {
32-
ctx.JSON(500, map[string]string{
33+
ctx.JSON(http.StatusInternalServerError, map[string]string{
3334
"err": err.Error(),
3435
})
3536
return
@@ -42,10 +43,10 @@ func RestoreRepo(ctx *myCtx.PrivateContext) {
4243
params.RepoName,
4344
params.Units,
4445
); err != nil {
45-
ctx.JSON(500, map[string]string{
46+
ctx.JSON(http.StatusInternalServerError, map[string]string{
4647
"err": err.Error(),
4748
})
4849
} else {
49-
ctx.Status(200)
50+
ctx.Status(http.StatusOK)
5051
}
5152
}

0 commit comments

Comments
 (0)