Documentation ¶
Overview ¶
Captain 'Jas' Hook: A Github Hook handler.
Jas can be included in a net/http server to listen on a path for github webhooks.
For a full guide visit http://github.com/wm/jas
package main import ( "net/http" "github.com/wm/jas/lib" ) func main() { j := jas.NewJas() j.RegisterHandlerFunc(jas.PushPayloadLogger) j.RegisterHandler(jas.NewFileChangeEmailer(jas.Options{ Emails: &[]string{"will@example.com", "eliot@example.com"}, Files: &[]string{"db/structure.sql", "db/schema.rb"}, })) mux := http.NewServeMux() mux.Handle("/", j) http.ListenAndServe(":1234", mux) }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PushPayloadLogger ¶
func PushPayloadLogger(e []string, p *github.WebHookPayload)
PushPayloadLogger prints some basic payload information for push events.
Types ¶
type FileChangeEmailer ¶
type FileChangeEmailer struct {
// contains filtered or unexported fields
}
FileChangeEmailer is a handler that captures the files changed and if it finds a match emails the relevant people.
func NewFileChangeEmailer ¶
func NewFileChangeEmailer(opt FileChangeEmailerOptions) *FileChangeEmailer
NewFileChangeEmailer returns a new FileChangeEmailer instance
func (*FileChangeEmailer) HandlePayload ¶
func (fce *FileChangeEmailer) HandlePayload(event []string, payload *github.WebHookPayload)
type FileChangeEmailerOptions ¶
type FileChangeEmailerOptions struct { // Emails is the list of email addresses to mail when a change is // detected Emails *[]string // Files is the list of files to monitor for change Files *[]string }
Options is a struct for specifying configuration options for the FileChangeEmailer jas.Handler
type Handler ¶
type Handler interface {
HandlePayload(e []string, p *github.WebHookPayload)
}
Handler handler is an interface that objects can implement to be registered to get called on incoming webhook payloads.
Each handler will have its HandlePayload method called in the order registered.
type HandlerFunc ¶
type HandlerFunc func(e []string, p *github.WebHookPayload)
HandlerFunc is an adapter to allow the use of ordinary functions as Jas handlers. If f is a function with the appropriate signature, HandlerFunc(f) is a Handler object who's HandlePayload method calls f.
func (HandlerFunc) HandlePayload ¶
func (h HandlerFunc) HandlePayload(e []string, p *github.WebHookPayload)
type Jas ¶
type Jas struct {
// contains filtered or unexported fields
}
Jas is a stack of Handlers that can be invoked as a Handler. Jas handlers are evaluated in the order that they are added to the stack using the Register and RegisterHandler methods.
func (*Jas) RegisterHandler ¶
RegisteHandlerr adds a Handler onto the handlers stack. Handlers are invoked in the order they are added.
func (*Jas) RegisterHandlerFunc ¶
func (j *Jas) RegisterHandlerFunc(handler HandlerFunc)
RegisterHandlerFunc adds a HandlerFunc onto the handlers stack. Handlers are invoked in the order they are added to a Negroni.