diff options
author | oliverpool <git@olivier.pfad.fr> | 2024-03-21 14:09:49 +0100 |
---|---|---|
committer | oliverpool <git@olivier.pfad.fr> | 2024-03-27 15:38:39 +0100 |
commit | 4ab341e9714b59fa009af44fb7de61642b6e6e86 (patch) | |
tree | 5ea99672deac9e5c4c699f9a652767a7ed8e44e6 /services/webhook | |
parent | [REFACTOR] webhook packagist endpoint (diff) | |
download | forgejo-4ab341e9714b59fa009af44fb7de61642b6e6e86.tar.xz forgejo-4ab341e9714b59fa009af44fb7de61642b6e6e86.zip |
[REFACTOR] webhook gogs endpoint
Diffstat (limited to 'services/webhook')
-rw-r--r-- | services/webhook/gogs.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/services/webhook/gogs.go b/services/webhook/gogs.go index 2ecd9e6d09..e23673ed35 100644 --- a/services/webhook/gogs.go +++ b/services/webhook/gogs.go @@ -4,9 +4,36 @@ package webhook import ( + "net/http" + + webhook_model "code.gitea.io/gitea/models/webhook" webhook_module "code.gitea.io/gitea/modules/webhook" + "code.gitea.io/gitea/services/forms" ) type gogsHandler struct{ defaultHandler } func (gogsHandler) Type() webhook_module.HookType { return webhook_module.GOGS } + +func (gogsHandler) FormFields(bind func(any)) FormFields { + var form struct { + forms.WebhookForm + PayloadURL string `binding:"Required;ValidUrl"` + ContentType int `binding:"Required"` + Secret string + } + bind(&form) + + contentType := webhook_model.ContentTypeJSON + if webhook_model.HookContentType(form.ContentType) == webhook_model.ContentTypeForm { + contentType = webhook_model.ContentTypeForm + } + return FormFields{ + WebhookForm: form.WebhookForm, + URL: form.PayloadURL, + ContentType: contentType, + Secret: form.Secret, + HTTPMethod: http.MethodPost, + Metadata: nil, + } +} |