bfe: Index | Files

package bfe_module

import ""


Package Files

bfe_callback.go bfe_filter.go bfe_handler_list.go bfe_module.go bfe_plugin.go bfe_plugin_info.go


const (
    HandleAccept         = 0
    HandleHandshake      = 1
    HandleBeforeLocation = 2
    HandleFoundProduct   = 3
    HandleAfterLocation  = 4
    HandleForward        = 5
    HandleReadResponse   = 6
    HandleRequestFinish  = 7
    HandleFinish         = 8

Callback point.

const (
    HandlersAccept   = 0 // for AcceptFilter
    HandlersRequest  = 1 // for RequestFilter
    HandlersForward  = 2 // for ForwardFilter
    HandlersResponse = 3 // for ResponseFilter
    HandlersFinish   = 4 // for FinishFilter

HandlerList type.

const (
    BfeHandlerFinish   = 0 // to close the connection after response
    BfeHandlerGoOn     = 1 // to go on next handler
    BfeHandlerRedirect = 2 // to redirect
    BfeHandlerResponse = 3 // to send response
    BfeHandlerClose    = 4 // to close the connection directly, with no data sent.

Return value of handler.

func AddModule Uses

func AddModule(module BfeModule)

AddModule adds module to moduleMap and modulesAll.

func CallbackPointName Uses

func CallbackPointName(point int) string

func ModConfDir Uses

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 Uses

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 Uses

func ModuleStatusGetJSON() ([]byte, error)

ModuleStatusGetJSON get modules Available and modules Enabled.

type AcceptFilter Uses

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

AcceptFilter filters incoming connections.

func NewAcceptFilter Uses

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

NewAcceptFilter creates a Filter by passed func

type BfeCallbacks Uses

type BfeCallbacks struct {
    // contains filtered or unexported fields

func NewBfeCallbacks Uses

func NewBfeCallbacks() *BfeCallbacks

NewBfeCallbacks creates a BfeCallbacks.

func (*BfeCallbacks) AddFilter Uses

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

AddFilter adds filter to given callback point.

func (*BfeCallbacks) GetHandlerList Uses

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

GetHandlerList gets handler list for given callback point

func (*BfeCallbacks) ModuleHandlersGetJSON Uses

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

ModuleHandlersGetJSON get info of hanlders

type BfeModule Uses

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 Uses

type BfeModules struct {
    // contains filtered or unexported fields

func NewBfeModules Uses

func NewBfeModules() *BfeModules

NewBfeModules create new BfeModules

func (*BfeModules) GetModule Uses

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

GetModule get work module by name.

func (*BfeModules) Init Uses

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

Init initializes bfe modules.


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

func (*BfeModules) RegisterModule Uses

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

RegisterModule register work module, only work module be inited

type BfePlugins Uses

type BfePlugins struct {
    // contains filtered or unexported fields

func NewBfePlugins Uses

func NewBfePlugins() *BfePlugins

NewPlugins create new Plugins

func (*BfePlugins) Init Uses

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

Init initializes bfe plugins.


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

func (*BfePlugins) RegisterPlugin Uses

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

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

type FinishFilter Uses

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

FinishFilter filters finished session(connection)

func NewFinishFilter Uses

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

NewFinishFilter create a Filter by passed func.

type ForwardFilter Uses

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

ForwardFilter filters to forward request

func NewForwardFilter Uses

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

NewForwardFilter create a Filter by passed func

type HandlerList Uses

type HandlerList struct {
    // contains filtered or unexported fields

func NewHandlerList Uses

func NewHandlerList(handlerType int) *HandlerList

NewHandlerList creates a HandlerList.

func (*HandlerList) AddAcceptFilter Uses

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

AddAcceptFilter adds accept filter to handler list.

func (*HandlerList) AddFinishFilter Uses

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

AddFinishFilter adds finish filter to handler list.

func (*HandlerList) AddForwardFilter Uses

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

AddForwardFilter adds forward filter to handler list.

func (*HandlerList) AddRequestFilter Uses

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

AddRequestFilter adds request filter to handler list.

func (*HandlerList) AddResponseFilter Uses

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

AddResponseFilter adds response filter to handler list.

func (*HandlerList) FilterAccept Uses

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

FilterAccept filters accept with HandlerList.

func (*HandlerList) FilterFinish Uses

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

FilterFinish filters finished session with HandlerList.

func (*HandlerList) FilterForward Uses

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

FilterForward filters forward with HandlerList.

func (*HandlerList) FilterRequest Uses

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

FilterRequest filters request with HandlerList.

func (*HandlerList) FilterResponse Uses

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

FilterResponse filters request with HandlerList.

type PluginInfo Uses

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 Uses

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

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

func NewRequestFilter Uses

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

NewRequestFilter create a Filter by passed func.

type ResponseFilter Uses

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 Uses

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

NewResponseFilter creates a Filter by passed func

Package bfe_module imports 12 packages (graph) and is imported by 41 packages. Updated 2020-08-11. Refresh now. Tools for package owners.