Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix API status code for hook creation #2814

Merged
merged 2 commits into from
Nov 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion public/swagger.v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -1527,7 +1527,7 @@
}
],
"responses": {
"200": {
"201": {
"$ref": "#/responses/Hook"
}
}
Expand Down
2 changes: 1 addition & 1 deletion routers/api/v1/repo/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions routers/api/v1/utils/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
}
}

Expand All @@ -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))
}
}

Expand Down