gohooks

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultSignatureHeader = "X-GoHooks-Verification"
)

Variables

This section is empty.

Functions

func IsGoHookValid

func IsGoHookValid(data interface{}, signature, secret string) bool

IsGoHookValid checks the sha256 of the data matches the one given on the signature.

Types

type GoHook

type GoHook struct {
	// Data to be sent in the GoHook
	Payload GoHookPayload
	// The encrypted SHA resulting with the used salt
	ResultingSha string
	// Prepared JSON marshaled data
	PreparedData []byte
	// Choice of signature header to use on sending a GoHook
	SignatureHeader string
	// Should validate SSL certificate
	IsSecure bool
	// Preferred HTTP method to send the GoHook
	// Please choose only POST, DELETE, PATCH or PUT
	// Any other value will make the send use POST as fallback
	PreferredMethod string
}

GoHook represents the definition of a GoHook.

func (*GoHook) Create

func (hook *GoHook) Create(data interface{}, resource, secret string)

Create creates a webhook to be sent to another system, with a SHA 256 signature based on its contents.

func (*GoHook) Send

func (hook *GoHook) Send(receiverURL string) (*http.Response, error)

Send sends a GoHook to the specified URL, as a UTF-8 JSON payload.

type GoHookPayload

type GoHookPayload struct {
	Resource string      `json:"resource"`
	Data     interface{} `json:"data"`
}

GoHookPayload represents the data that will be sent in the GoHook.

Jump to

Keyboard shortcuts

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