mirror of
https://github.com/go-gitea/gitea.git
synced 2024-10-29 08:17:31 -04:00
api: delete repository webhooks (#3275)
Allows the deletion of a webhook from a repository at the /:user/:repo/hooks/:id endpoint. Solves drone/drone issue #1603. Signed-off-by: Dennis Chen <barracks510@gmail.com>
This commit is contained in:
parent
eac32419fc
commit
5ff2dfb23e
@ -221,9 +221,12 @@ func RegisterRoutes(m *macaron.Macaron) {
|
|||||||
Delete(repo.Delete)
|
Delete(repo.Delete)
|
||||||
|
|
||||||
m.Group("/:username/:reponame", func() {
|
m.Group("/:username/:reponame", func() {
|
||||||
m.Combo("/hooks").Get(repo.ListHooks).
|
m.Group("/hooks", func() {
|
||||||
Post(bind(api.CreateHookOption{}), repo.CreateHook)
|
m.Combo("").Get(repo.ListHooks).
|
||||||
m.Patch("/hooks/:id:int", bind(api.EditHookOption{}), repo.EditHook)
|
Post(bind(api.CreateHookOption{}), repo.CreateHook)
|
||||||
|
m.Combo("/:id:int").Patch(bind(api.EditHookOption{}), repo.EditHook).
|
||||||
|
Delete(repo.DeleteHook)
|
||||||
|
})
|
||||||
m.Get("/raw/*", context.RepoRef(), repo.GetRawFile)
|
m.Get("/raw/*", context.RepoRef(), repo.GetRawFile)
|
||||||
m.Get("/archive/*", repo.GetArchive)
|
m.Get("/archive/*", repo.GetArchive)
|
||||||
m.Group("/branches", func() {
|
m.Group("/branches", func() {
|
||||||
|
@ -96,6 +96,15 @@ func CreateHook(ctx *context.APIContext, form api.CreateHookOption) {
|
|||||||
ctx.JSON(201, convert.ToHook(ctx.Repo.RepoLink, w))
|
ctx.JSON(201, convert.ToHook(ctx.Repo.RepoLink, w))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DeleteHook(ctx *context.APIContext) {
|
||||||
|
if err := models.DeleteWebhook(ctx.ParamsInt64(":id")); err != nil {
|
||||||
|
ctx.Error(500, "DeleteWebhook", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.Status(204)
|
||||||
|
}
|
||||||
|
|
||||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#edit-a-hook
|
// https://github.com/gogits/go-gogs-client/wiki/Repositories#edit-a-hook
|
||||||
func EditHook(ctx *context.APIContext, form api.EditHookOption) {
|
func EditHook(ctx *context.APIContext, form api.EditHookOption) {
|
||||||
w, err := models.GetWebhookByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
|
w, err := models.GetWebhookByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
|
||||||
|
Loading…
Reference in New Issue
Block a user