webhook

package
v11.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadSignature = errors.New("webhook: signature verification failed")
	ErrClientError  = errors.New("webhook: client error (4xx)")
	ErrServerError  = errors.New("webhook: server error after all retries")
)

Functions

func VerifyPayload

func VerifyPayload(headers http.Header, body []byte, secret string) ([]byte, error)

VerifyPayload verifies a webhook payload signature on the receive side, discarding the signed delivery ID. Prefer VerifyPayloadID so replayed delivery IDs can be deduplicated.

func VerifyPayloadID added in v11.3.0

func VerifyPayloadID(headers http.Header, body []byte, secret string) (string, []byte, error)

VerifyPayloadID verifies a webhook payload signature on the receive side and returns the signed delivery ID. The ID is covered by the HMAC so receivers can safely use it to deduplicate replayed deliveries within the timestamp window.

Wire format (v11.2+): signature input is "timestamp.id.body".

Types

type Delivery

type Delivery struct {
	ID        string
	URL       string
	Status    string // "delivered", "failed", "pending"
	Attempts  int
	LastError string
	SentAt    time.Time
}

type Option

type Option func(*Sender)

func MaxAttempts

func MaxAttempts(n int) Option

type Sender

type Sender struct {
	// contains filtered or unexported fields
}

func NewSender

func NewSender(opts ...Option) *Sender

func (*Sender) Send

func (s *Sender) Send(url string, payload any, secret string) (string, error)

func (*Sender) Status

func (s *Sender) Status(id string) (Delivery, bool)

Jump to

Keyboard shortcuts

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