Documentation
¶
Overview ¶
Package webhooks delivers outgoing webhooks to subscribers — signed, asynchronous, and retried (Spatie webhook-server / Svix style for togo).
Register subscriptions (a URL + the events it wants + a signing secret), then Send an event: every matching subscriber receives an HMAC-SHA256-signed POST, delivered over the kernel Queue (with exponential-backoff retries) when one is configured, or inline otherwise. Every attempt is recorded in a delivery log.
s, _ := webhooks.FromKernel(k)
sub := s.Subscribe("https://acme.test/hooks", []string{"order.paid"}, "whsec_…")
s.Send(ctx, "order.paid", map[string]any{"id": 42})
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Delivery ¶
type Delivery struct {
ID string `json:"id"`
SubID string `json:"subscription_id"`
Event string `json:"event"`
Attempt int `json:"attempt"`
Status int `json:"status"`
Succeeded bool `json:"succeeded"`
Error string `json:"error,omitempty"`
At time.Time `json:"at"`
}
Delivery records a single delivery attempt.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the webhooks runtime stored on the kernel (k.Get("webhooks")).
func FromKernel ¶
FromKernel returns the webhooks Service registered on the kernel.
func (*Service) Deliveries ¶
Deliveries returns the recent delivery log (most recent last).
func (*Service) Send ¶
Send dispatches an event to every matching subscriber. Delivery is async over the queue when available, else inline.
func (*Service) Subscribe ¶
func (s *Service) Subscribe(url string, events []string, secret string) *Subscription
Subscribe registers an endpoint for the given events ("*" = all).
func (*Service) Subscriptions ¶
func (s *Service) Subscriptions() []Subscription
Subscriptions lists all registered subscriptions.
func (*Service) Unsubscribe ¶
Unsubscribe removes a subscription.