{"action":"created","issue":{"url":"https://api.github.com/repos/adnanh/webhook/issues/7","labels_url":"https://api.github.com/repos/adnanh/webhook/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/adnanh/webhook/issues/7/comments","events_url":"https://api.github.com/repos/adnanh/webhook/issues/7/events","html_url":"https://github.com/adnanh/webhook/issues/7","id":62858655,"number":7,"title":"Posts as x-www-form-urlencoded don't work","user":{"login":"moorereason","id":131056,"avatar_url":"https://avatars.githubusercontent.com/u/131056?v=3","gravatar_id":"","url":"https://api.github.com/users/moorereason","html_url":"https://github.com/moorereason","followers_url":"https://api.github.com/users/moorereason/followers","following_url":"https://api.github.com/users/moorereason/following{/other_user}","gists_url":"https://api.github.com/users/moorereason/gists{/gist_id}","starred_url":"https://api.github.com/users/moorereason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moorereason/subscriptions","organizations_url":"https://api.github.com/users/moorereason/orgs","repos_url":"https://api.github.com/users/moorereason/repos","events_url":"https://api.github.com/users/moorereason/events{/privacy}","received_events_url":"https://api.github.com/users/moorereason/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/adnanh/webhook/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":{"login":"adnanh","id":82367,"avatar_url":"https://avatars.githubusercontent.com/u/82367?v=3","gravatar_id":"","url":"https://api.github.com/users/adnanh","html_url":"https://github.com/adnanh","followers_url":"https://api.github.com/users/adnanh/followers","following_url":"https://api.github.com/users/adnanh/following{/other_user}","gists_url":"https://api.github.com/users/adnanh/gists{/gist_id}","starred_url":"https://api.github.com/users/adnanh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adnanh/subscriptions","organizations_url":"https://api.github.com/users/adnanh/orgs","repos_url":"https://api.github.com/users/adnanh/repos","events_url":"https://api.github.com/users/adnanh/events{/privacy}","received_events_url":"https://api.github.com/users/adnanh/received_events","type":"User","site_admin":false},"milestone":null,"comments":4,"created_at":"2015-03-19T03:06:07Z","updated_at":"2015-03-19T21:24:52Z","closed_at":null,"body":"First off, thanks for publishing this project.  It looks promising.\r\n\r\nI ran into an issue trying to receive a POST hook from Bitbucket.  Bitbucket sends a x-www-form-urlencoded POST with the JSON content in the ``payload`` form variable -- they don't send the JSON payload in the body.  I was able to modify ``hookHandler()`` to decode the JSON, but I had to hardcode the ``payload`` map index:\r\n\r\n```go\r\n} else if contentType == \"application/x-www-form-urlencoded\" {\r\n    fd, err := url.ParseQuery(string(body))\r\n    if err != nil {\r\n        log.Printf(\"error parsing form payload %+v\\n\", err)\r\n    } else {\r\n        fv := helpers.ValuesToMap(fd)\r\n        decoder := json.NewDecoder(strings.NewReader(fv[\"payload\"].(string)))\r\n        decoder.UseNumber()\r\n        err := decoder.Decode(&payload)\r\n        if err != nil {\r\n            log.Printf(\"error parsing JSON payload %+v\\n\", err)\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nWith that change, I'm able to match simple paths (``canon_url`` and ``repository.absolute_url``), but I'm unable to match ``commits.0.branch``.  I've yet to look into why.\r\n\r\nI'm testing webhook with curl and sending [Bitbucket's sample payload](https://confluence.atlassian.com/display/BITBUCKET/POST+hook+management).  Here's a simplified version of what I'm doing:\r\n\r\n```\r\ncurl -X POST -H \"Content-Type: application/x-www-form-urlencoded\" \\\r\n  -d 'payload={\"canon_url\": \"https://bitbucket.org\"}' \\\r\n  http://localhost:9000/hooks/example\r\n```\r\n\r\nI wanted to see if you can duplicate the form decoding problem.  I also wanted to see what you think about adding another option to the hook definition format.  I'm thinking something like ``form-variable`` would work.  I would set that to ``payload``, and webhook would know to access that form variable to find the JSON payload."},"comment":{"url":"https://api.github.com/repos/adnanh/webhook/issues/comments/83764434","html_url":"https://github.com/adnanh/webhook/issues/7#issuecomment-83764434","issue_url":"https://api.github.com/repos/adnanh/webhook/issues/7","id":83764434,"user":{"login":"adnanh","id":82367,"avatar_url":"https://avatars.githubusercontent.com/u/82367?v=3","gravatar_id":"","url":"https://api.github.com/users/adnanh","html_url":"https://github.com/adnanh","followers_url":"https://api.github.com/users/adnanh/followers","following_url":"https://api.github.com/users/adnanh/following{/other_user}","gists_url":"https://api.github.com/users/adnanh/gists{/gist_id}","starred_url":"https://api.github.com/users/adnanh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adnanh/subscriptions","organizations_url":"https://api.github.com/users/adnanh/orgs","repos_url":"https://api.github.com/users/adnanh/repos","events_url":"https://api.github.com/users/adnanh/events{/privacy}","received_events_url":"https://api.github.com/users/adnanh/received_events","type":"User","site_admin":false},"created_at":"2015-03-19T21:24:52Z","updated_at":"2015-03-19T21:24:52Z","body":"Exactly that. Maybe `parse-parameters-value-as-json`? :-)"}}