From d38c0286d7b0d307e9a074fdea24c758590cc0d3 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Wed, 12 May 2021 15:08:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AF=B7=E6=B1=82=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E5=8F=AF=E8=83=BD=E4=BC=9A=E9=87=8D=E5=A4=8D=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/serverconfigs/shared/http_request_cond.go | 6 +++--- pkg/serverconfigs/shared/http_request_cond_group.go | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) 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()