diff --git a/pkg/serverconfigs/shared/http_request_cond.go b/pkg/serverconfigs/shared/http_request_cond.go index a077401..047d867 100644 --- a/pkg/serverconfigs/shared/http_request_cond.go +++ b/pkg/serverconfigs/shared/http_request_cond.go @@ -16,7 +16,7 @@ import ( "strings" ) -// 重写条件定义 +// HTTPRequestCond HTTP请求匹配条件定义 type HTTPRequestCond struct { Type string `yaml:"type" json:"type"` // 类型,在特殊条件时使用 IsRequest bool `yaml:"isRequest" json:"isRequest"` // 是否为请求的条件,用来区分在什么阶段执行 @@ -39,7 +39,7 @@ type HTTPRequestCond struct { arrayValue []string } -// 校验配置 +// Init 校验配置 func (this *HTTPRequestCond) Init() error { this.isInt = RegexpDigitNumber.MatchString(this.Value) this.isFloat = RegexpFloatNumber.MatchString(this.Value) @@ -134,7 +134,7 @@ func (this *HTTPRequestCond) Init() error { return nil } -// 将此条件应用于请求,检查是否匹配 +// Match 将此条件应用于请求,检查是否匹配 func (this *HTTPRequestCond) Match(formatter func(source string) string) bool { paramValue := formatter(this.Param) switch this.Operator { diff --git a/pkg/serverconfigs/shared/http_request_cond_group.go b/pkg/serverconfigs/shared/http_request_cond_group.go index 086002d..a980244 100644 --- a/pkg/serverconfigs/shared/http_request_cond_group.go +++ b/pkg/serverconfigs/shared/http_request_cond_group.go @@ -1,6 +1,6 @@ package shared -// 请求条件分组 +// HTTPRequestCondGroup 请求条件分组 type HTTPRequestCondGroup struct { IsOn bool `yaml:"isOn" json:"isOn"` // 是否启用 Connector string `yaml:"connector" json:"connector"` // 条件之间的关系 @@ -12,12 +12,14 @@ type HTTPRequestCondGroup struct { responseConds []*HTTPRequestCond } -// 初始化 +// Init 初始化 func (this *HTTPRequestCondGroup) Init() error { if len(this.Connector) == 0 { this.Connector = "or" } + this.requestConds = []*HTTPRequestCond{} + this.responseConds = []*HTTPRequestCond{} if len(this.Conds) > 0 { for _, cond := range this.Conds { err := cond.Init()