types

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseResponseWriter

type BaseResponseWriter struct {
	http.ResponseWriter
}

Base wrapper that other plugins can embed

func (*BaseResponseWriter) Header

func (b *BaseResponseWriter) Header() http.Header

func (*BaseResponseWriter) Unwrap

func (*BaseResponseWriter) Write

func (b *BaseResponseWriter) Write(data []byte) (int, error)

func (*BaseResponseWriter) WriteHeader

func (b *BaseResponseWriter) WriteHeader(statusCode int)

type Plugin

type Plugin interface {
	//If the plugin returns final, no further plugins will be executed
	//The res at this stage won't have any data written from upstream and plugin can use to early return a response
	HandleRequest(req *http.Request, res http.ResponseWriter) (final bool, err error)
	// HandleResponse should be used when the plugin needs to act on the upstream response.
	//NOTE: If the plugin wraps responsewriter then make sure to implement hijacker or websocket requests will fail
	HandleResponse(*http.Request, http.ResponseWriter) http.ResponseWriter
	Priority() int
	GetConfig() PluginConf
	ValidateAndSetConfig(PluginConf) error //Returns any validation error
	Destroy()                              // garbage collection
}

type PluginConf

type PluginConf map[string]any

TODO: Make this a little more dynamic.

type PluginFactory

type PluginFactory func(logger *logger.Logger) Plugin

type Registry

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

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Get

func (r *Registry) Get(typ string) (PluginFactory, bool)

func (*Registry) Register

func (r *Registry) Register(typ string, pluginFactory PluginFactory)

type ResponseWriterWrapper

type ResponseWriterWrapper interface {
	http.ResponseWriter
	Unwrap() http.ResponseWriter
}

Jump to

Keyboard shortcuts

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