Documentation ¶
Overview ¶
Package ghooks is a github hooks receiver in golang with net/http.
Inspired by GitHub::Hooks::Receiver (https://github.com/Songmu/Github-Hooks-Receiver), and octoks (https://github.com/hisaichi5518/octoks)
Install
go get github.com/erikh/ghooks
Usage
// sample.go package main import ( "fmt" "log" "github.com/erikh/ghooks" ) func main() { port := 8080 hooks := ghooks.NewServer(port) hooks.On("push", pushHandler) hooks.On("pull_request", pullRequestHandler) hooks.Run() } func pushHandler(payload interface{}) { fmt.Println("puuuuush") } func pullRequestHandler(payload interface{}) { fmt.Println("pull_request") }
After starting this server:
curl -H "X-GitHub-Event: push" -d '{"hoge":"fuga"}' http://localhost:8080 > puuuuush
Index ¶
Constants ¶
View Source
const (
// Version is the version of the library
Version = 0.2
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hook ¶
type Hook struct { Event string Func func(payload interface{}) }
Hook is the type of hook event being processed.
type Server ¶
type Server struct {
Secret string
}
Server is the hander pipeline for serving github hooks. One can instantiate a server
Click to show internal directories.
Click to hide internal directories.