mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2026-02-08 14:35:39 +08:00
增加边缘脚本相关配置
This commit is contained in:
33
pkg/serverconfigs/http_request_scripts_config.go
Normal file
33
pkg/serverconfigs/http_request_scripts_config.go
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
|
||||
package serverconfigs
|
||||
|
||||
type HTTPRequestScriptsConfig struct {
|
||||
OnInitScript *JSScriptConfig `yaml:"onInitScript" json:"onInitScript"` // 接收到请求之后
|
||||
OnRequestScript *JSScriptConfig `yaml:"onRequestScript" json:"onRequestScript"` // 准备转发请求之前
|
||||
}
|
||||
|
||||
func (this *HTTPRequestScriptsConfig) Init() error {
|
||||
if this.OnInitScript != nil {
|
||||
err := this.OnInitScript.Init()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if this.OnRequestScript != nil {
|
||||
err := this.OnRequestScript.Init()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *HTTPRequestScriptsConfig) IsEmpty() bool {
|
||||
if (this.OnInitScript == nil || !this.OnInitScript.IsOn) && (this.OnRequestScript == nil || !this.OnRequestScript.IsOn) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user