filter

package
v0.4.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterHttpFilter

func RegisterHttpFilter(f HttpFilterPlugin)

Register registers filter plugin.

func RegisterNetworkFilter

func RegisterNetworkFilter(f NetworkFilterPlugin)

Register registers network filter.

Types

type FilterManager

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

FilterManager manage filters

func NewEmptyFilterManager

func NewEmptyFilterManager() *FilterManager

NewEmptyFilterManager create empty filter manager

func NewFilterManager

func NewFilterManager(fs []*model.HTTPFilter) *FilterManager

NewFilterManager create filter manager

func (*FilterManager) Apply

func (fm *FilterManager) Apply(name string, conf map[string]interface{}) (HttpFilter, error)

Apply return a new filter by name & conf

func (*FilterManager) GetFilters

func (fm *FilterManager) GetFilters() []*HttpFilter

GetFilters get all filter from manager

func (*FilterManager) Load

func (fm *FilterManager) Load()

Load the filter from config

func (*FilterManager) ReLoad

func (fm *FilterManager) ReLoad(filters []*model.HTTPFilter)

ReLoad filter configs

type HttpFilter

type HttpFilter interface {
	// PrepareFilterChain add filter into chain
	PrepareFilterChain(ctx *http.HttpContext) error

	// Handle filter hook function
	Handle(ctx *http.HttpContext)

	Apply() error

	// Config get config for filter
	Config() interface{}
}

HttpFilter describe http filter

type HttpFilterPlugin

type HttpFilterPlugin interface {
	// Kind returns the unique kind name to represent itself.
	Kind() string

	// CreateFilter return the filter callback
	CreateFilter() (HttpFilter, error)
}

HttpFilterPlugin describe plugin

func GetHttpFilterPlugin

func GetHttpFilterPlugin(kind string) (HttpFilterPlugin, error)

GetHttpFilterPlugin get plugin by kind

type NetworkFilter

type NetworkFilter interface {
	// OnData handle the http context from worker
	OnData(hc *http.HttpContext) error
}

NetworkFilter describe network filter

type NetworkFilterPlugin

type NetworkFilterPlugin interface {
	// Kind returns the unique kind name to represent itself.
	Kind() string
	// CreateFilterFactory return the filter callback
	CreateFilter(config interface{}, bs *model.Bootstrap) (NetworkFilter, error)
}

NetworkFilter describe network filter plugin

func GetNetworkFilterPlugin

func GetNetworkFilterPlugin(kind string) (NetworkFilterPlugin, error)

GetNetworkFilterPlugin get plugin by kind

Jump to

Keyboard shortcuts

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