ingest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package ingest accepts inbound webhooks.

Rule: nothing about a payload's content may cause a rejection. A malformed body, an unknown provider and an unmapped event type are all recorded.

Index

Constants

View Source
const DefaultMaxBodyBytes int64 = 1 << 20

A resource limit, not content validation: a body that cannot be held cannot be recorded, and 413 is the only honest answer.

View Source
const DefaultTenant = "default"

DefaultTenant is the tenant an address without one belongs to, so a single tenant deployment needs no slug in its webhook URLs.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MaxBodyBytes int64
	Verification Verification
	Logger       *slog.Logger
}

type Handler

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

func New

func New(store Store, cfg Config) *Handler

func (*Handler) Receive

func (h *Handler) Receive(w http.ResponseWriter, r *http.Request)

func (*Handler) Register

func (h *Handler) Register(mux *http.ServeMux)

type Store

type Store interface {
	// Record returns the identifier the event was recorded under, which the
	// database makes: nothing can know it before the row exists.
	Record(ctx context.Context, req inbound.Request) (uuid.UUID, error)
	// Tenant reports the tenant of a slug, and whether there is one. An
	// address for a tenant that does not exist and a database that cannot
	// answer are different failures and get different answers.
	Tenant(ctx context.Context, slug string) (uuid.UUID, bool, error)
}

Store is what accepting a request needs: somewhere to record it and a way to resolve the tenant it was addressed to.

type Verification

type Verification interface {
	Verifier(tenant uuid.UUID, provider string) provider.Verifier
}

Verification hands over the verifier for a tenant's provider, already built, so that checking a request costs no query and no construction.

Jump to

Keyboard shortcuts

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