Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrChecksumMismatch = errors.New("calculated checksum does not match request header") ErrNotImplemented = errors.New("no implementation for event type") )
Functions ¶
Types ¶
type WebhookServer ¶
type WebhookServer struct {
// contains filtered or unexported fields
}
WebhookServer will accept HTTP requests from a Github webhook server and process them. It has an embedded HTTP server to use standalone, but also implements http.Handler so that it can be used in your web server of choice, if you are embedding it elsewhere.
func NewWebhookServer ¶
func NewWebhookServer(handler any, options *WebhookServerProps) (*WebhookServer, error)
NewWebhookServer will create a WebhookServer with the given handler and options. The handler parameter must be a pointer to a struct that implements one or more of the public *EventHandler interfaces defined in this package
func (*WebhookServer) ServeHTTP ¶
func (s *WebhookServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP will receive and respond to webhook events
func (*WebhookServer) Start ¶
func (s *WebhookServer) Start()
func (*WebhookServer) Stop ¶
func (s *WebhookServer) Stop()
type WebhookServerProps ¶
type WebhookServerProps struct {
// The IP and port for the server to listen on (or ":<port>" to listen on all available IPs)
Addr string
// The path specified on the webhook server, if any
Path string
// The secret key created when registering the webhook, used to verify requests
SecretKey string
// If set and StrictSecurity is set to true, requests will be validated that the Host header matches this value
ExternalHostName string
// If true, all HTTP errors will return 404 instead of the appropriate semantic error code (to mask interior workings)
// and will return empty bodies instead of error information. If ExternalHostName is also set, requests will have their
// Host headers verified
StrictSecurity bool
// The number of goroutines that will be dedicated to handling webhook requests. If outside the range (0, 255], defaults to 10
WorkerPoolSize int
// If true, all webhook events will be handled synchronously with respect to the calling request. Note that Github requires
// that a webhook event be responded to within 10 seconds
Synchronous bool
// If set, all internal loggers will use this logger as the root. If nil, slog.Default will be used
RootLogger *slog.Logger
}
WebhookServerProps includes all the things the server needs to know about to run
Click to show internal directories.
Click to hide internal directories.