hooks

package
v0.0.0-...-2443087 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2022 License: BSD-3-Clause Imports: 7 Imported by: 1

Documentation

Overview

hooks is the entrypoint for this project: it handles the GitHub webhooks and funnels the data into the various action functions registered to it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventHandler

type EventHandler func(context *ctx.Context, event interface{}) error

EventHandler is An event handler takes in a given event and operates on it.

type EventHandlerMap

type EventHandlerMap map[EventType][]EventHandler

func (EventHandlerMap) AddHandler

func (m EventHandlerMap) AddHandler(eventType EventType, handler EventHandler)

type EventType

type EventType string
var (
	CommitCommentEvent            EventType = "commit_comment"
	CreateEvent                   EventType = "create"
	DeleteEvent                   EventType = "delete"
	DeploymentEvent               EventType = "deployment"
	DeploymentStatusEvent         EventType = "deployment_status"
	ForkEvent                     EventType = "fork"
	GollumEvent                   EventType = "gollum"
	IssueCommentEvent             EventType = "issue_comment"
	IssuesEvent                   EventType = "issues"
	MemberEvent                   EventType = "member"
	MembershipEvent               EventType = "membership"
	PageBuildEvent                EventType = "page_build"
	PublicEvent                   EventType = "public"
	PullRequestEvent              EventType = "pull_request"
	PullRequestReviewEvent        EventType = "pull_request_review"
	PullRequestReviewCommentEvent EventType = "pull_request_review_comment"
	PushEvent                     EventType = "push"
	ReleaseEvent                  EventType = "release"
	RepositoryEvent               EventType = "repository"
	StatusEvent                   EventType = "status"
	TeamAddEvent                  EventType = "team_add"
	WatchEvent                    EventType = "watch"
)

func (EventType) String

func (e EventType) String() string

type GlobalHandler

type GlobalHandler struct {
	Context       *ctx.Context
	EventHandlers EventHandlerMap
	// contains filtered or unexported fields
}

GlobalHandler is a handy handler which can take in every event, choose which handlers to fire, and fires them.

func (*GlobalHandler) AcceptedEventTypes

func (h *GlobalHandler) AcceptedEventTypes() []EventType

AcceptedEventTypes returns an array of all event types the GlobalHandler can accept.

func (*GlobalHandler) FireHandlers

func (h *GlobalHandler) FireHandlers(handlers []EventHandler, eventType string, payload []byte) int

func (*GlobalHandler) HandlePayload

func (h *GlobalHandler) HandlePayload(w http.ResponseWriter, r *http.Request, payload []byte)

HandlePayload handles the actual unpacking of the payload and firing of the proper handlers. It will never respond with anything but a 200.

func (*GlobalHandler) ServeHTTP

func (h *GlobalHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles the incoming HTTP request, validates the payload and fires

type HookHandler

type HookHandler interface {
	HandlePayload(w http.ResponseWriter, r *http.Request, payload []byte)
}

HookHandler describes the interface for any type which can handle a webhook payload.

type Repo

type Repo struct {
	Owner, Name string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL