github

package
v1.7.4 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package github is GitHub's webhook protocol: its calls are signed, with the secret, in X-Hub-Signature-256, say what happened in X-GitHub-Event, and the body's action, and their delivery in X-GitHub-Delivery. A call whose content type is a form has its JSON in the form's payload field.

https://docs.github.com/en/webhooks/using-webhooks/validating-webhook-deliveries

Index

Constants

View Source
const (
	// Name is the protocol's name
	Name = "github"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Protocol

type Protocol struct{}

Protocol is GitHub's protocol

func New

func New() Protocol

New returns the protocol

func (Protocol) Check added in v1.7.4

func (Protocol) Check(method string, header http.Header) error

Check returns nil when the call is a POST, with its event in X-GitHub-Event, as every call of GitHub's is

func (Protocol) Decode

func (Protocol) Decode(header http.Header, body []byte) (json.RawMessage, error)

Decode returns the body, or, when it's a form, its payload field, which is the JSON

func (Protocol) Handshake

func (Protocol) Handshake(*http.Request, string) ([]byte, bool)

func (Protocol) Headers

func (Protocol) Headers() []string

func (Protocol) Identify

func (Protocol) Identify(header http.Header, values json.RawMessage) (string, string)

Identify returns X-GitHub-Event, and the body's action, when it has one, such as issues.opened, and X-GitHub-Delivery

func (Protocol) Name

func (Protocol) Name() string

func (Protocol) Sample added in v1.7.4

func (Protocol) Sample(delivery string) (http.Header, []byte)

Sample returns a ping, which GitHub sends when a webhook is set up

func (Protocol) Sign added in v1.7.4

func (Protocol) Sign(header http.Header, body []byte, secret string)

Sign sets X-Hub-Signature-256

func (Protocol) Verify

func (Protocol) Verify(header http.Header, body []byte, secret string) error

Verify returns nil when X-Hub-Signature-256 is sha256=, and the body's HMAC-SHA256, with the secret, in hex

Jump to

Keyboard shortcuts

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