Documentation ¶
Overview ¶
Package plugins
@author: xwc1125
Package plugins ¶
@author: xwc1125
Package plugins ¶
@author: xwc1125
Index ¶
- Variables
- func ConfToProto(pluginName string, pluginConf string) []byte
- func CreateRuleConf(uniqueKey string, entries []ConfInfo) []byte
- func HTTPReqCall(key string, req *fasthttp.Request, resp *fasthttp.Response) error
- func HTTPRespCall(key string, resp *fasthttp.Response) error
- func PrepareConf(key string, pluginsConf map[string]interface{}) (string, error)
- func RegisterPlugin(plugin Plugin) error
- type ConfCache
- type ConfEntry
- type ConfInfo
- type DefaultPlugin
- type ErrPluginRegistered
- type Plugin
- type Plugins
- type RuleConf
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrMissingName = errors.New("missing name") ErrMissingParseConfMethod = errors.New("missing ParseConf method") ErrMissingRequestFilterMethod = errors.New("missing RequestFilter method") ErrMissingResponseFilterMethod = errors.New("missing ResponseFilter method") RequestPhase = requestPhase{} // 请求阶段 ResponsePhase = responsePhase{} // 响应阶段 )
Functions ¶
func ConfToProto ¶
ConfToProto plugin conf to proto bytes
func CreateRuleConf ¶
func HTTPReqCall ¶
HTTPReqCall http请求的调用
func HTTPRespCall ¶
HTTPRespCall http 响应的调用
func PrepareConf ¶
PrepareConf 将请求的数据进行缓存
func RegisterPlugin ¶
Types ¶
type ConfCache ¶
type ConfCache struct {
// contains filtered or unexported fields
}
func InitConfCache ¶
type DefaultPlugin ¶
type DefaultPlugin struct{}
DefaultPlugin 插件接口的无操作实现
func (*DefaultPlugin) RequestFilter ¶
func (*DefaultPlugin) ResponseFilter ¶
func (*DefaultPlugin) ResponseFilter(conf interface{}, w *fasthttp.Response) error
type ErrPluginRegistered ¶
type ErrPluginRegistered struct {
// contains filtered or unexported fields
}
func (ErrPluginRegistered) Error ¶
func (err ErrPluginRegistered) Error() string
type Plugin ¶
type Plugin interface { // Name 插件名称 Name() string // Version 版本信息 Version() string // Priority 优先级 Priority() int64 // ParseConf 解析插件配置 // 如果无法解析,那么跳过改插件 ParseConf(in []byte) (conf interface{}, err error) // RequestFilter 根据conf对象进行request的处理 // 当err不为nil时,代表执行出错,那么将会直接返回错误。 // 当w被改写时,即w.StatusCode!=fasthttp.StatusOK时,会跳出插件链的执行 RequestFilter(conf interface{}, r *fasthttp.Request, w *fasthttp.Response) (err error) // ResponseFilter 对相应结果的处理 ResponseFilter(conf interface{}, w *fasthttp.Response) (err error) }
Plugin 插件接口
Directories ¶
Path | Synopsis |
---|---|
Package plugins
|
Package plugins |
cgw
Package cgw
|
Package cgw |
cgw/cgw_v2
Package cgw_v2
|
Package cgw_v2 |
Click to show internal directories.
Click to hide internal directories.