8000 Highlights README syntax by rjz · Pull Request #3 · rjz/githubhook · GitHub
[go: up one dir, main page]

Skip to content

Highlights README syntax #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 8, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Highlights README syntax
  • Loading branch information
rjz committed Jun 7, 2016
commit 5887ea7ed9cd5d854f0d9eb6f8ebcecf7f4357c7
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,29 @@ be integrated with one.
Installation
-----------------------------------------------

$ go get github.com/rjz/githubhook
```ShellSession
$ go get github.com/rjz/githubhook
```

Usage
-----------------------------------------------

Given an incoming `*http.Request` representing a webhook signed with a `secret`,
use `githubhook` to validate and parse its content:

secret := []byte("don't tell!")
hook, err := githubhook.Parse(secret, req)
```go
secret := []byte("don't tell!")
hook, err := githubhook.Parse(secret, req)
```

Plays nicely with the [google/go-github][gh-go-github] client!

evt := github.PullRequestEvent{}
if err := json.Unmarshal(hook.Payload, &evt); err != nil {
fmt.Println("Invalid JSON?", err)
}
```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
0