hooks

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(reg Registration) error

func ResetRegistryForTesting

func ResetRegistryForTesting()

ResetRegistryForTesting clears the registry; meant for use in tests.

func SortByPriority

func SortByPriority(hooks []ResolvedHook)

Types

type ClientCert

type ClientCert struct {
	Leaf        *x509.Certificate
	Chain       []*x509.Certificate
	Fingerprint string
}

type CompletionHook

type CompletionHook func(ctx context.Context, rc ResponseCtx) error

type Kind

type Kind string
const (
	OnRequestReceived  Kind = "on_request_received"
	OnRequestCompleted Kind = "on_request_completed"
)

type Matcher

type Matcher struct {
	Host       string
	PathPrefix string
	Methods    []string
}

func (Matcher) Matches

func (m Matcher) Matches(rc RequestCtx) bool

type Registration

type Registration struct {
	Name     string
	Kind     Kind
	Handler  any
	Priority int
}

func Lookup

func Lookup(name string) (Registration, bool)

func Registered

func Registered() []Registration

type RequestCtx

type RequestCtx struct {
	Req        *http.Request
	Host       string
	Path       string
	TraceID    string
	ClientIP   string
	Meta       map[string]string
	ClientCert *ClientCert
}

type RequestHook

type RequestHook func(ctx context.Context, rc RequestCtx) error

type ResolvedHook

type ResolvedHook struct {
	Registration Registration
	Matcher      Matcher
	Timeout      time.Duration
}

type ResponseCtx

type ResponseCtx struct {
	ReqCtx  RequestCtx
	Status  int
	Headers http.Header
	Err     error
	Latency time.Duration
}

Jump to

Keyboard shortcuts

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