githubhook

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2019 License: MIT Imports: 8 Imported by: 8

README

GitHub webhook

GitHub webhook HTTP Handler in Go (Golang)

GoDoc Build Status

Features

  • HTTP Handler
  • Secret validation
  • JSON or form content type
  • Custom payload decoding

Documentation

Overview

Package githubhook provides a HTTP Handler for GitHub webhook.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	Secret        string
	DecodePayload func(event string, rawPayload []byte) (interface{}, error)
	Delivery      func(event string, deliveryID string, payload interface{})
	Error         func(err error, req *http.Request)
}

Handler is a HTTP Handler for GitHub webhook.

It supports both JSON and form content types.

Fields (all are optional):

  • Secret is the secret defined in GitHub webhook.
  • DecodePayload is called to decode payload. If it's not defined, JSON unmarshal is used.
  • Delivery is called if a valid delivery is received.
  • Error is called if an error happened.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, req *http.Request)

type RequestError

type RequestError struct {
	StatusCode int
	Message    string
}

RequestError represents a request error

func (*RequestError) Error

func (err *RequestError) Error() string

Jump to

Keyboard shortcuts

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