aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEthan Koenig <ethantkoenig@gmail.com>2017-11-19 23:00:53 -0800
committerLunny Xiao <xiaolunwen@gmail.com>2017-11-20 15:00:53 +0800
commit876bafb7ef8570e62de026b999acd05556fceaee (patch)
treee6aae270ee1f30327af74d5b15b03d907d39c0be
parent061f65ff297d3c2bb76776af999f80a891a74933 (diff)
downloadgitea-876bafb7ef8570e62de026b999acd05556fceaee.tar.gz
gitea-876bafb7ef8570e62de026b999acd05556fceaee.zip
Fix API status code for hook creation (#2814)
* Fix API status code for hook creation * Named constants for response statuses
-rw-r--r--public/swagger.v1.json2
-rw-r--r--routers/api/v1/repo/hook.go2
-rw-r--r--routers/api/v1/utils/hook.go5
3 files changed, 5 insertions, 4 deletions
diff --git a/public/swagger.v1.json b/public/swagger.v1.json
index 82370e49e2..6072bfba3b 100644
--- a/public/swagger.v1.json
+++ b/public/swagger.v1.json
@@ -1527,7 +1527,7 @@
}
],
"responses": {
- "200": {
+ "201": {
"$ref": "#/responses/Hook"
}
}
diff --git a/routers/api/v1/repo/hook.go b/routers/api/v1/repo/hook.go
index 2464cc7bd7..eb1742ac56 100644
--- a/routers/api/v1/repo/hook.go
+++ b/routers/api/v1/repo/hook.go
@@ -107,7 +107,7 @@ func CreateHook(ctx *context.APIContext, form api.CreateHookOption) {
// schema:
// "$ref": "#/definitions/CreateHookOption"
// responses:
- // "200":
+ // "201":
// "$ref": "#/responses/Hook"
if !utils.CheckCreateHookOption(ctx, &form) {
return
diff --git a/routers/api/v1/utils/hook.go b/routers/api/v1/utils/hook.go
index ab67accc5b..e1533da94c 100644
--- a/routers/api/v1/utils/hook.go
+++ b/routers/api/v1/utils/hook.go
@@ -12,6 +12,7 @@ import (
"code.gitea.io/gitea/routers/api/v1/convert"
"encoding/json"
"github.com/Unknwon/com"
+ "net/http"
)
// GetOrgHook get an organization's webhook. If there is an error, write to
@@ -69,7 +70,7 @@ func AddOrgHook(ctx *context.APIContext, form *api.CreateHookOption) {
org := ctx.Org.Organization
hook, ok := addHook(ctx, form, org.ID, 0)
if ok {
- ctx.JSON(200, convert.ToHook(org.HomeLink(), hook))
+ ctx.JSON(http.StatusCreated, convert.ToHook(org.HomeLink(), hook))
}
}
@@ -78,7 +79,7 @@ func AddRepoHook(ctx *context.APIContext, form *api.CreateHookOption) {
repo := ctx.Repo
hook, ok := addHook(ctx, form, 0, repo.Repository.ID)
if ok {
- ctx.JSON(200, convert.ToHook(repo.RepoLink, hook))
+ ctx.JSON(http.StatusCreated, convert.ToHook(repo.RepoLink, hook))
}
}