webhook

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventHeader       = "X-Authara-Event"
	DeliveryHeader    = "X-Authara-Delivery"
	DeliverySemantics = "best_effort"

	RetryReasonNetworkError = "network_error"
	RetryReasonHTTP429      = "http_429"
	RetryReasonHTTP5xx      = "http_5xx"
	RetryReasonOtherHTTP4xx = "other_http_4xx"
)
View Source
const (
	SignatureHeader    = "X-Authara-Signature"
	SignaturePrefix    = "sha256="
	SignatureAlgorithm = "hmac-sha256"
	SignatureFormat    = "sha256=<hex>"
)

Variables

View Source
var RetryNotOn = []string{
	RetryReasonOtherHTTP4xx,
}
View Source
var SupportedEventTypes = []EventType{
	EventUserCreated,
	EventUserDeleted,
}

Functions

func Sign

func Sign(secret string, body []byte) string

Types

type Envelope

type Envelope struct {
	ID        string    `json:"id"`
	Type      EventType `json:"type"`
	CreatedAt time.Time `json:"created_at"`
	Data      any       `json:"data"`
}

func NewUserCreated

func NewUserCreated(userID uuid.UUID, now time.Time) Envelope

func NewUserDeleted

func NewUserDeleted(userID uuid.UUID, now time.Time) Envelope

type EventType

type EventType string
const (
	EventUserCreated EventType = "user.created"
	EventUserDeleted EventType = "user.deleted"
)

type FilteringPublisher

type FilteringPublisher struct {
	Inner   Publisher
	Enabled map[string]struct{}
}

func NewFilteringPublisher

func NewFilteringPublisher(inner Publisher, enabled map[string]struct{}) *FilteringPublisher

func (*FilteringPublisher) Publish

func (p *FilteringPublisher) Publish(ctx context.Context, evt Envelope) error

type NoopPublisher

type NoopPublisher struct{}

func (NoopPublisher) Publish

func (NoopPublisher) Publish(ctx context.Context, evt Envelope) error

type Publisher

type Publisher interface {
	Publish(ctx context.Context, evt Envelope) error
}

type Sender

type Sender struct {
	URL      string
	Secret   string
	Client   *http.Client
	Attempts int
	Backoff  []time.Duration
}

func NewSender

func NewSender(url, secret string, client *http.Client) *Sender

func (*Sender) Publish

func (s *Sender) Publish(ctx context.Context, evt Envelope) error

type UserData

type UserData struct {
	UserID uuid.UUID `json:"user_id"`
}

Jump to

Keyboard shortcuts

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