Documentation ¶
Index ¶
- Constants
- func AddModule(module BfeModule)
- func CallbackPointName(point int) string
- func ModConfDir(confRoot string, modName string) string
- func ModConfPath(confRoot string, modName string) string
- func ModuleStatusGetJSON() ([]byte, error)
- type AcceptFilter
- type BfeCallbacks
- type BfeModule
- type BfeModules
- type BfePlugins
- type FinishFilter
- type ForwardFilter
- type HandlerList
- func (hl *HandlerList) AddAcceptFilter(f interface{}) error
- func (hl *HandlerList) AddFinishFilter(f interface{}) error
- func (hl *HandlerList) AddForwardFilter(f interface{}) error
- func (hl *HandlerList) AddRequestFilter(f interface{}) error
- func (hl *HandlerList) AddResponseFilter(f interface{}) error
- func (hl *HandlerList) FilterAccept(session *bfe_basic.Session) int
- func (hl *HandlerList) FilterFinish(session *bfe_basic.Session) int
- func (hl *HandlerList) FilterForward(req *bfe_basic.Request) int
- func (hl *HandlerList) FilterRequest(req *bfe_basic.Request) (int, *bfe_http.Response)
- func (hl *HandlerList) FilterResponse(req *bfe_basic.Request, res *bfe_http.Response) int
- type PluginInfo
- type RequestFilter
- type ResponseFilter
Constants ¶
const ( HandleAccept = iota HandleHandshake HandleBeforeLocation HandleFoundProduct HandleAfterLocation HandleForward HandleReadResponse HandleRequestFinish HandleFinish )
Callback point.
const ( // HandlersAccept for AcceptFilter HandlersAccept = iota // HandlersRequest for RequestFilter HandlersRequest // HandlersForward for ForwardFilter HandlersForward // HandlersResponse for ResponseFilter HandlersResponse // HandlersFinish for FinishFilter HandlersFinish )
HandlerList type.
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 ModConfDir ¶
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 ¶
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 ¶
ModuleStatusGetJSON get modules Available and modules Enabled.
Types ¶
type AcceptFilter ¶
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 (*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 (*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 (*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 ¶
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 ¶
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 ¶
FilterRequest filters request with HandlerList.
func (*HandlerList) FilterResponse ¶
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 ¶
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 ¶
NewResponseFilter creates a Filter by passed func