webhook

package
v1.233.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoTemplateEvaluator added in v1.165.0

type GoTemplateEvaluator struct{}

GoTemplateEvaluator evaluates Go template expressions against JSON payloads

func NewGoTemplateEvaluator added in v1.165.0

func NewGoTemplateEvaluator() *GoTemplateEvaluator

NewGoTemplateEvaluator creates a new GoTemplateEvaluator

func (*GoTemplateEvaluator) Evaluate added in v1.165.0

func (e *GoTemplateEvaluator) Evaluate(payload map[string]interface{}, templateStr string) (bool, error)

Evaluate evaluates a Go template expression against a payload The template should return "true" or "false" as a string Returns true if the template evaluates to "true", false otherwise

func (*GoTemplateEvaluator) FuncMap added in v1.198.0

func (e *GoTemplateEvaluator) FuncMap() template.FuncMap

FuncMap returns custom template functions

type SignatureConfig

type SignatureConfig struct {
	// HeaderName is the name of the HTTP header containing the signature
	// Examples: "X-Hub-Signature-256", "X-Signature"
	HeaderName string

	// Secret is the shared secret used for HMAC computation
	Secret string

	// Algorithm specifies the hash algorithm to use
	// Supported values: "sha256", "sha1", "sha512"
	Algorithm string
}

SignatureConfig contains configuration for signature verification

type SignatureVerifier

type SignatureVerifier struct{}

SignatureVerifier provides HMAC signature verification for webhooks

func NewSignatureVerifier

func NewSignatureVerifier() *SignatureVerifier

NewSignatureVerifier creates a new SignatureVerifier

func (*SignatureVerifier) Verify

func (v *SignatureVerifier) Verify(payload []byte, signatureHeader string, config SignatureConfig) bool

Verify verifies an HMAC signature against a payload Returns true if the signature is valid, false otherwise

func (*SignatureVerifier) VerifyGitHubSignature

func (v *SignatureVerifier) VerifyGitHubSignature(payload []byte, signatureHeader, secret string) bool

VerifyGitHubSignature is a convenience method for verifying GitHub webhook signatures It handles both X-Hub-Signature (SHA1) and X-Hub-Signature-256 (SHA256)

Jump to

Keyboard shortcuts

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