webhook

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultSignatureHeader is used as default signature header
	DefaultSignatureHeader = "X-GoWebHooks-Verification"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GoWebHook

type GoWebHook struct {
	// Data to be sent in the GoWebHook
	Payload GoWebHookPayload
	// 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 GoWebHook
	SignatureHeader string
	// Should validate SSL certificate
	IsSecure bool
	// Preferred HTTP method to send the GoWebHook
	// Please choose only POST, DELETE, PATCH or PUT
	// Any other value will make the send use POST as fallback
	PreferredMethod string
	// Additional HTTP headers to be added to the hook
	AdditionalHeaders map[string]string
}

GoWebHook represents the definition of a GoWebHook.

func (*GoWebHook) Create

func (hook *GoWebHook) 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 (*GoWebHook) Send

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

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

type GoWebHookPayload

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

GoWebHookPayload represents the data that will be sent in the GoWebHook.

type Repository

type Repository struct {
	FullName   string `json:"full_name"`
	PullNumber string `json:"pull_number"`
}

Repository struct - part of Webhook struct

type Webhook

type Webhook struct {
	Path          string `json:"path"`
	RepositoryURL string `json:"repository_url"`
	Repository    `json:"repository"`
}

Webhook struct used for sending webhooks to https://smee.io/

func (*Webhook) CreateAndSend

func (w *Webhook) CreateAndSend(saltSecret, webhookTarget string) (*http.Response, error)

CreateAndSend creates and then sends a webhook to the given target

Jump to

Keyboard shortcuts

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