webhook

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package webhook provides a webhook publisher for the outbox pattern. It sends HTTP POST requests to configured endpoints for each outbox message.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Publisher)

Option configures a webhook Publisher.

func WithDefaultHeaders

func WithDefaultHeaders(headers map[string]string) Option

WithDefaultHeaders sets default headers added to all requests.

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient sets a custom HTTP client.

func WithTimeout

func WithTimeout(d time.Duration) Option

WithTimeout sets the HTTP request timeout.

type Publisher

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

Publisher publishes outbox messages as HTTP POST requests. Destination format: "webhook:https://example.com/events"

func New

func New(opts ...Option) *Publisher

New creates a new webhook Publisher.

func (*Publisher) Destination

func (p *Publisher) Destination() string

Destination returns the destination prefix this publisher handles.

func (*Publisher) Publish

func (p *Publisher) Publish(ctx context.Context, messages []*adapters.OutboxMessage) error

Publish sends each outbox message as an HTTP POST to the URL specified in the destination. The URL is extracted from the destination by removing the "webhook:" prefix. All messages are attempted even if some fail; errors are collected and returned as a joined error.

Jump to

Keyboard shortcuts

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