https://github.com/rjz/githubhook
Github webhook parser in golang
https://github.com/rjz/githubhook
github github-hook github-webhooks golang
Last synced: 8 months ago
JSON representation
Github webhook parser in golang
- Host: GitHub
- URL: https://github.com/rjz/githubhook
- Owner: rjz
- License: other
- Created: 2015-10-19T03:48:45.000Z (about 10 years ago)
- Default Branch: main
- Last Pushed: 2023-12-26T16:16:59.000Z (almost 2 years ago)
- Last Synced: 2025-04-28T16:14:20.352Z (8 months ago)
- Topics: github, github-hook, github-webhooks, golang
- Language: Go
- Size: 13.7 KB
- Stars: 53
- Watchers: 4
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
githubhook
===============================================
Golang parser for [github webhooks][gh-webhook]. Not a server, though it could
be integrated with one.
[](https://goreportcard.com/report/github.com/rjz/githubhook)
[](https://godoc.org/github.com/rjz/githubhook)
Installation
-----------------------------------------------
```ShellSession
$ go get gopkg.in/rjz/githubhook.v0
```
Usage
-----------------------------------------------
Given an incoming `*http.Request` representing a webhook signed with a `secret`,
use `githubhook` to validate and parse its content:
```go
secret := []byte("don't tell!")
hook, err := githubhook.Parse(secret, req)
```
Plays nicely with the [google/go-github][gh-go-github] client!
```go
evt := github.PullRequestEvent{}
if err := json.Unmarshal(hook.Payload, &evt); err != nil {
fmt.Println("Invalid JSON?", err)
}
```
[gh-webhook]: https://developer.github.com/webhooks/
[gh-go-github]: https://github.com/google/go-github