internal

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(secret string, l logger.Logger, fn WebHookHandler) http.HandlerFunc

func HashPayload

func HashPayload(secret string, playloadBody []byte) string

HashPayload computes the hash of payload's body according to the webhook's secret token see https://developer.github.com/webhooks/securing/#validating-payloads-from-github returning the hash as a hexadecimal string

func IsValidPayload

func IsValidPayload(secret, headerHash string, payload []byte) bool

IsValidPayload checks if the github payload's hash fits with the hash computed by GitHub sent as a header

Types

type GitHubRepo

type GitHubRepo struct {
	Name        string // repository name
	FullName    string // repository full name
	CloneURL    string // repository url
	CommitID    string // push commit id
	CommitName  string // push repo name
	CommitEmail string // push repo email
	CommitAt    string // push time
	BranchName  string // branch name
}

repo info

type PayloadPong

type PayloadPong struct {
	Ok    bool   `json:"ok"`
	Event string `json:"event"`
	Error string `json:"error,omitempty"`
}

type WebHookHandler

type WebHookHandler func(eventName string, payload *GitHubRepo, req *http.Request) error

Jump to

Keyboard shortcuts

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