1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2025-12-17 21:57:29 +02:00

get githook hook payload from either form or json

This commit is contained in:
Brad Rydzewski
2014-09-06 10:23:36 -07:00
parent 5f3b882c0c
commit 8ad36255de
2 changed files with 18 additions and 6 deletions

View File

@@ -212,11 +212,9 @@ func (r *GitHub) ParseHook(req *http.Request) (*model.Hook, error) {
return r.ParsePullRequestHook(req)
}
// get the payload of the message
var payload = req.FormValue("payload")
// parse the github Hook payload
var data, err = github.ParseHook([]byte(payload))
var payload = GetPayload(req)
var data, err = github.ParseHook(payload)
if err != nil {
return nil, nil
}
@@ -259,11 +257,11 @@ func (r *GitHub) ParseHook(req *http.Request) (*model.Hook, error) {
// ParsePullRequestHook parses the pull request hook from the Request body
// and returns the required data in a standard format.
func (r *GitHub) ParsePullRequestHook(req *http.Request) (*model.Hook, error) {
var payload = req.FormValue("payload")
// parse the payload to retrieve the pull-request
// hook meta-data.
var data, err = github.ParsePullRequestHook([]byte(payload))
var payload = GetPayload(req)
var data, err = github.ParsePullRequestHook(payload)
if err != nil {
return nil, err
}