webhook

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HMAC

type HMAC struct {
	Header string
	SigKey string
	Secret string
}

HMAC configures signature validation of incoming request bodies.

type Metrics

type Metrics struct {
	RequestCount    metric.Int64Counter
	RequestDuration metric.Float64Histogram
}

Metrics holds the instruments the webhook source records, mirroring the names, descriptions and units of the Python MetricsMiddleware.

func NewMetrics

func NewMetrics(mp metric.MeterProvider) (*Metrics, error)

NewMetrics builds the instruments from a meter provider. Passing a nil or noop provider yields instruments that record nothing, so the request path needs no nil checks.

type Option

type Option func(*Source)

func WithAddr

func WithAddr(addr string) Option

WithAddr overrides the listen address. Tests use it to bind port 0.

func WithHMAC

func WithHMAC(h *HMAC) Option

func WithLogger

func WithLogger(logger *zap.Logger) Option

func WithMeterProvider

func WithMeterProvider(mp metric.MeterProvider) Option

WithMeterProvider records request metrics against the given provider. A nil provider leaves the source recording nothing.

type Source

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

func NewSource

func NewSource(opts ...Option) (*Source, error)

func (*Source) Addr

func (s *Source) Addr() string

Addr reports the bound address, which only differs from the configured one when the port was left to the kernel.

func (*Source) Close

func (s *Source) Close() error

func (*Source) Commit

func (s *Source) Commit() error

func (*Source) HMACConfig

func (s *Source) HMACConfig() *HMAC

HMACConfig reports the signature validation in effect, nil when bodies are accepted unvalidated.

func (*Source) Handler

func (s *Source) Handler() http.Handler

Handler is the webhook endpoint, exposed so it can be served on a listener the caller owns.

func (*Source) Start

func (s *Source) Start() error

func (*Source) Stream

func (s *Source) Stream() <-chan []core.Message

Jump to

Keyboard shortcuts

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