bfe_module

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2022 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

View Source
const (
	HandleAccept = iota
	HandleHandshake
	HandleBeforeLocation
	HandleFoundProduct
	HandleAfterLocation
	HandleForward
	HandleReadResponse
	HandleRequestFinish
	HandleFinish
)

Callback point.

View Source
const (
	// HandlersAccept for AcceptFilter
	HandlersAccept = iota
	// HandlersRequest for RequestFilter
	HandlersRequest
	// HandlersForward for ForwardFilter
	HandlersForward
	// HandlersResponse for ResponseFilter
	HandlersResponse
	// HandlersFinish for FinishFilter
	HandlersFinish
)

HandlerList type.

View Source
const (
	// BfeHandlerFinish to close the connection after response
	BfeHandlerFinish = iota
	// BfeHandlerGoOn to go on next handler
	BfeHandlerGoOn
	// BfeHandlerRedirect to redirect
	BfeHandlerRedirect
	// BfeHandlerResponse to send response
	BfeHandlerResponse
	// BfeHandlerClose to close the connection directly, with no data sent.
	BfeHandlerClose
)

Return value of handler.

Variables

This section is empty.

Functions

func AddModule

func AddModule(module BfeModule)

AddModule adds module to moduleMap and modulesAll.

func CallbackPointName

func CallbackPointName(point int) string

func ModConfDir

func ModConfDir(confRoot string, modName string) string

ModConfDir get dir for module config.

format: confRoot/<modName>

e.g., confRoot = "/home/bfe/conf", modName = "mod_access" return "/home/bfe/conf/mod_access"

func ModConfPath

func ModConfPath(confRoot string, modName string) string

ModConfPath get full path of module config file.

format: confRoot/<modName>/<modName>.conf

e.g., confRoot = "/home/bfe/conf", modName = "mod_access" return "/home/bfe/conf/mod_access/mod_access.conf"

func ModuleStatusGetJSON

func ModuleStatusGetJSON() ([]byte, error)

ModuleStatusGetJSON get modules Available and modules Enabled.

Types

type AcceptFilter

type AcceptFilter interface {
	FilterAccept(*bfe_basic.Session) int
}

AcceptFilter filters incoming connections.

func NewAcceptFilter

func NewAcceptFilter(f func(session *bfe_basic.Session) int) AcceptFilter

NewAcceptFilter creates a Filter by passed func

type BfeCallbacks

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

func NewBfeCallbacks

func NewBfeCallbacks() *BfeCallbacks

NewBfeCallbacks creates a BfeCallbacks.

func (*BfeCallbacks) AddFilter

func (bcb *BfeCallbacks) AddFilter(point int, f interface{}) error

AddFilter adds filter to given callback point.

func (*BfeCallbacks) GetHandlerList

func (bcb *BfeCallbacks) GetHandlerList(point int) *HandlerList

GetHandlerList gets handler list for given callback point

func (*BfeCallbacks) ModuleHandlersGetJSON

func (bcb *BfeCallbacks) ModuleHandlersGetJSON() ([]byte, error)

ModuleHandlersGetJSON get info of handlers

type BfeModule

type BfeModule interface {
	// Name return name of module.
	Name() string

	// Init initializes the module.
	//
	// Params:
	//      - cbs: callback handlers. for register call back function
	//      - whs: web monitor handlers. for register web monitor handler
	//      - cr: config root path. for get config path of module
	Init(cbs *BfeCallbacks, whs *web_monitor.WebHandlers, cr string) error
}

type BfeModules

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

func NewBfeModules

func NewBfeModules() *BfeModules

NewBfeModules create new BfeModules

func (*BfeModules) GetModule

func (bm *BfeModules) GetModule(name string) BfeModule

GetModule get work module by name.

func (*BfeModules) Init

func (bm *BfeModules) Init(cbs *BfeCallbacks, whs *web_monitor.WebHandlers, cr string) error

Init initializes bfe modules.

Params:

  • cbs: BfeCallbacks
  • whs: WebHandlers
  • cr : root path for config

func (*BfeModules) RegisterModule

func (bm *BfeModules) RegisterModule(name string) error

RegisterModule register work module, only work module be inited

type BfePlugins

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

func NewBfePlugins

func NewBfePlugins() *BfePlugins

NewBfePlugins create new Plugins

func (*BfePlugins) Init

func (p *BfePlugins) Init(cbs *BfeCallbacks, whs *web_monitor.WebHandlers, cr string) error

Init initializes bfe plugins.

Params:

  • cbs: BfeCallbacks
  • whs: WebHandlers
  • cr : root path for config

func (*BfePlugins) RegisterPlugin

func (p *BfePlugins) RegisterPlugin(path string, bfeVersion string) error

RegisterPlugin loads a plugin created with `go build -buildmode=plugin`

type FinishFilter

type FinishFilter interface {
	FilterFinish(*bfe_basic.Session) int
}

FinishFilter filters finished session(connection)

func NewFinishFilter

func NewFinishFilter(f func(session *bfe_basic.Session) int) FinishFilter

NewFinishFilter create a Filter by passed func.

type ForwardFilter

type ForwardFilter interface {
	FilterForward(*bfe_basic.Request) int
}

ForwardFilter filters to forward request

func NewForwardFilter

func NewForwardFilter(f func(req *bfe_basic.Request) int) ForwardFilter

NewForwardFilter create a Filter by passed func

type HandlerList

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

func NewHandlerList

func NewHandlerList(handlerType int) *HandlerList

NewHandlerList creates a HandlerList.

func (*HandlerList) AddAcceptFilter

func (hl *HandlerList) AddAcceptFilter(f interface{}) error

AddAcceptFilter adds accept filter to handler list.

func (*HandlerList) AddFinishFilter

func (hl *HandlerList) AddFinishFilter(f interface{}) error

AddFinishFilter adds finish filter to handler list.

func (*HandlerList) AddForwardFilter

func (hl *HandlerList) AddForwardFilter(f interface{}) error

AddForwardFilter adds forward filter to handler list.

func (*HandlerList) AddRequestFilter

func (hl *HandlerList) AddRequestFilter(f interface{}) error

AddRequestFilter adds request filter to handler list.

func (*HandlerList) AddResponseFilter

func (hl *HandlerList) AddResponseFilter(f interface{}) error

AddResponseFilter adds response filter to handler list.

func (*HandlerList) FilterAccept

func (hl *HandlerList) FilterAccept(session *bfe_basic.Session) int

FilterAccept filters accept with HandlerList.

func (*HandlerList) FilterFinish

func (hl *HandlerList) FilterFinish(session *bfe_basic.Session) int

FilterFinish filters finished session with HandlerList.

func (*HandlerList) FilterForward

func (hl *HandlerList) FilterForward(req *bfe_basic.Request) int

FilterForward filters forward with HandlerList.

func (*HandlerList) FilterRequest

func (hl *HandlerList) FilterRequest(req *bfe_basic.Request) (int, *bfe_http.Response)

FilterRequest filters request with HandlerList.

func (*HandlerList) FilterResponse

func (hl *HandlerList) FilterResponse(req *bfe_basic.Request, res *bfe_http.Response) int

FilterResponse filters request with HandlerList.

type PluginInfo

type PluginInfo struct {
	Name        string
	Version     string
	Description string
	Kind        string // TODO plugin kind
	Path        string
	Init        func(cbs *BfeCallbacks, whs *web_monitor.WebHandlers, cr string) error
}

type RequestFilter

type RequestFilter interface {
	FilterRequest(request *bfe_basic.Request) (int, *bfe_http.Response)
}

RequestFilter filters incoming requests and return a response or nil. Filters are chained together into a HandlerList.

func NewRequestFilter

func NewRequestFilter(f func(request *bfe_basic.Request) (int, *bfe_http.Response)) RequestFilter

NewRequestFilter create a Filter by passed func.

type ResponseFilter

type ResponseFilter interface {
	FilterResponse(req *bfe_basic.Request, res *bfe_http.Response) int
}

ResponseFilter filters outgoing responses. This can be used to modify the response before it is sent.

func NewResponseFilter

func NewResponseFilter(f func(req *bfe_basic.Request, res *bfe_http.Response) int) ResponseFilter

NewResponseFilter creates a Filter by passed func

Jump to

Keyboard shortcuts

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