Files
EdgeCommon/pkg/serverconfigs/http_request_scripts_config.go

43 lines
1010 B
Go
Raw Permalink Normal View History

2024-05-17 18:28:59 +08:00
// Copyright 2021 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
2022-01-01 21:51:15 +08:00
package serverconfigs
type HTTPRequestScriptsConfig struct {
2022-01-03 21:51:24 +08:00
InitGroup *ScriptGroupConfig `yaml:"initGroup" json:"initGroup"`
RequestGroup *ScriptGroupConfig `yaml:"requestGroup" json:"requestGroup"`
2022-01-01 21:51:15 +08:00
}
func (this *HTTPRequestScriptsConfig) Init() error {
2022-01-03 21:51:24 +08:00
if this.InitGroup != nil {
err := this.InitGroup.Init()
2022-01-01 21:51:15 +08:00
if err != nil {
return err
}
}
2022-01-03 21:51:24 +08:00
if this.RequestGroup != nil {
err := this.RequestGroup.Init()
2022-01-01 21:51:15 +08:00
if err != nil {
return err
}
}
return nil
}
func (this *HTTPRequestScriptsConfig) IsEmpty() bool {
2022-01-03 21:51:24 +08:00
return (this.InitGroup == nil || this.InitGroup.IsEmpty()) &&
(this.RequestGroup == nil || this.RequestGroup.IsEmpty())
2022-01-01 21:51:15 +08:00
}
2023-12-23 20:55:01 +08:00
func (this *HTTPRequestScriptsConfig) AllGroups() []*ScriptGroupConfig {
var result []*ScriptGroupConfig
if this.InitGroup != nil {
result = append(result, this.InitGroup)
}
if this.RequestGroup != nil {
result = append(result, this.RequestGroup)
}
return result
}