hook

package
v0.0.0-...-eadd4a4 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package hook provides observation points for framework lifecycle events. Unlike plugins, hooks observe framework behaviour without extending it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hooks

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

Hooks holds all registered hooks for each observation point.

func Load

func Load(r *http.Request) *Hooks

Load retrieves the registry from the request context.

func (*Hooks) AddOnError

func (reg *Hooks) AddOnError(f OnErrorFunc)

AddOnError registers a hook that fires when HandleError is called.

func (*Hooks) AddOnRequest

func (reg *Hooks) AddOnRequest(f OnRequestFunc)

AddOnRequest registers a hook that fires on every incoming request.

func (*Hooks) AddOnRespond

func (reg *Hooks) AddOnRespond(f OnRespondFunc)

AddOnRespond registers a hook that fires when Respond is called.

func (*Hooks) Inject

func (reg *Hooks) Inject(r *http.Request) *http.Request

Inject stores the registry in the request context.

func (*Hooks) NotifyError

func (reg *Hooks) NotifyError(r *http.Request, err error)

NotifyError calls all registered OnError hooks.

func (*Hooks) NotifyRequest

func (reg *Hooks) NotifyRequest(r *http.Request)

NotifyRequest calls all registered OnRequest hooks.

func (*Hooks) NotifyRespond

func (reg *Hooks) NotifyRespond(r *http.Request, statusCode int)

NotifyRespond calls all registered OnRespond hooks.

type OnErrorFunc

type OnErrorFunc func(r *http.Request, err error)

OnErrorFunc is called when HandleError writes an error response.

type OnRequestFunc

type OnRequestFunc func(r *http.Request)

OnRequestFunc is called when an incoming request is received, before dispatch.

type OnRespondFunc

type OnRespondFunc func(r *http.Request, statusCode int)

OnRespondFunc is called when Respond writes a successful response.

Jump to

Keyboard shortcuts

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