https://github.com/superseb/webhooks
:fishing_pole_and_fish: Webhook receiver for GitHub, Bitbucket, GitLab, Gogs
https://github.com/superseb/webhooks
Last synced: 7 months ago
JSON representation
:fishing_pole_and_fish: Webhook receiver for GitHub, Bitbucket, GitLab, Gogs
- Host: GitHub
- URL: https://github.com/superseb/webhooks
- Owner: superseb
- License: mit
- Fork: true (go-playground/webhooks)
- Created: 2022-06-08T12:18:17.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-08T12:49:39.000Z (about 4 years ago)
- Last Synced: 2024-06-21T09:48:30.715Z (about 2 years ago)
- Homepage:
- Size: 459 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Library webhooks
================

[](https://github.com/go-playground/webhooks/actions)
[](https://coveralls.io/github/go-playground/webhooks?branch=master)
[](https://goreportcard.com/report/go-playground/webhooks)
[](https://godoc.org/github.com/go-playground/webhooks/v6)

Library webhooks allows for easy receiving and parsing of GitHub, Bitbucket and GitLab Webhook Events
Features:
* Parses the entire payload, not just a few fields.
* Fields + Schema directly lines up with webhook posted json
Notes:
* Currently only accepting json payloads.
Installation
------------
Use go get.
```shell
go get -u github.com/go-playground/webhooks/v6
```
Then import the package into your own code.
import "github.com/go-playground/webhooks/v6"
Usage and Documentation
------
Please see http://godoc.org/github.com/go-playground/webhooks/v6 for detailed usage docs.
##### Examples:
```go
package main
import (
"fmt"
"net/http"
"github.com/go-playground/webhooks/v6/github"
)
const (
path = "/webhooks"
)
func main() {
hook, _ := github.New(github.Options.Secret("MyGitHubSuperSecretSecrect...?"))
http.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) {
payload, err := hook.Parse(r, github.ReleaseEvent, github.PullRequestEvent)
if err != nil {
if err == github.ErrEventNotFound {
// ok event wasn;t one of the ones asked to be parsed
}
}
switch payload.(type) {
case github.ReleasePayload:
release := payload.(github.ReleasePayload)
// Do whatever you want from here...
fmt.Printf("%+v", release)
case github.PullRequestPayload:
pullRequest := payload.(github.PullRequestPayload)
// Do whatever you want from here...
fmt.Printf("%+v", pullRequest)
}
})
http.ListenAndServe(":3000", nil)
}
```
Contributing
------
Pull requests for other services are welcome!
If the changes being proposed or requested are breaking changes, please create an issue for discussion.
License
------
Distributed under MIT License, please see license file in code for more details.