实现缓存策略的部分功能

This commit is contained in:
GoEdgeLab
2020-10-05 16:54:21 +08:00
parent 1f11037d45
commit fcd9e4de06
5 changed files with 114 additions and 25 deletions

View File

@@ -6,6 +6,9 @@ type HTTPRequestCondsConfig struct {
IsOn bool `yaml:"isOn" json:"isOn"`
Connector string `yaml:"connector" json:"connector"`
Groups []*HTTPRequestCondGroup `yaml:"groups" json:"groups"`
hasRequestConds bool
hasResponseConds bool
}
// 初始化
@@ -21,6 +24,18 @@ func (this *HTTPRequestCondsConfig) Init() error {
}
}
// 是否有请求条件
for _, group := range this.Groups {
if group.IsOn {
if group.HasRequestConds() {
this.hasRequestConds = true
}
if group.HasResponseConds() {
this.hasResponseConds = true
}
}
}
return nil
}
@@ -67,3 +82,13 @@ func (this *HTTPRequestCondsConfig) MatchResponse(formatter func(s string) strin
}
return ok
}
// 判断是否有请求条件
func (this *HTTPRequestCondsConfig) HasRequestConds() bool {
return this.hasRequestConds
}
// 判断是否有响应条件
func (this *HTTPRequestCondsConfig) HasResponseConds() bool {
return this.hasResponseConds
}