[REFACTOR] webhook gogs endpoint
This commit is contained in:
parent
dce754cde1
commit
4ab341e971
4 changed files with 27 additions and 44 deletions
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue