aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1/org/hook.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/api/v1/org/hook.go')
-rw-r--r--routers/api/v1/org/hook.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/routers/api/v1/org/hook.go b/routers/api/v1/org/hook.go
index c7b0bd5b6b..b3faac7b51 100644
--- a/routers/api/v1/org/hook.go
+++ b/routers/api/v1/org/hook.go
@@ -5,6 +5,8 @@
package org
import (
+ "net/http"
+
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/convert"
@@ -28,17 +30,18 @@ func ListHooks(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/HookList"
+
org := ctx.Org.Organization
orgHooks, err := models.GetWebhooksByOrgID(org.ID)
if err != nil {
- ctx.Error(500, "GetWebhooksByOrgID", err)
+ ctx.Error(http.StatusInternalServerError, "GetWebhooksByOrgID", err)
return
}
hooks := make([]*api.Hook, len(orgHooks))
for i, hook := range orgHooks {
hooks[i] = convert.ToHook(org.HomeLink(), hook)
}
- ctx.JSON(200, hooks)
+ ctx.JSON(http.StatusOK, hooks)
}
// GetHook get an organization's hook by id
@@ -63,13 +66,14 @@ func GetHook(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/Hook"
+
org := ctx.Org.Organization
hookID := ctx.ParamsInt64(":id")
hook, err := utils.GetOrgHook(ctx, org.ID, hookID)
if err != nil {
return
}
- ctx.JSON(200, convert.ToHook(org.HomeLink(), hook))
+ ctx.JSON(http.StatusOK, convert.ToHook(org.HomeLink(), hook))
}
// CreateHook create a hook for an organization
@@ -159,15 +163,16 @@ func DeleteHook(ctx *context.APIContext) {
// responses:
// "204":
// "$ref": "#/responses/empty"
+
org := ctx.Org.Organization
hookID := ctx.ParamsInt64(":id")
if err := models.DeleteWebhookByOrgID(org.ID, hookID); err != nil {
if models.IsErrWebhookNotExist(err) {
ctx.NotFound()
} else {
- ctx.Error(500, "DeleteWebhookByOrgID", err)
+ ctx.Error(http.StatusInternalServerError, "DeleteWebhookByOrgID", err)
}
return
}
- ctx.Status(204)
+ ctx.Status(http.StatusNoContent)
}