From e22cf451f4c18d19a9eb79911c4c4d120ea81b0d Mon Sep 17 00:00:00 2001 From: Shelikhoo Date: Fri, 5 Mar 2021 18:37:32 +0000 Subject: [PATCH] Allow bulk definition of domain matcher at parent level --- infra/conf/router.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/infra/conf/router.go b/infra/conf/router.go index b7b892c47..11fadcfc8 100644 --- a/infra/conf/router.go +++ b/infra/conf/router.go @@ -41,6 +41,8 @@ type RouterConfig struct { RuleList []json.RawMessage `json:"rules"` DomainStrategy *string `json:"domainStrategy"` Balancers []*BalancingRule `json:"balancers"` + + DomainMatcher string `json:"domainMatcher"` } func (c *RouterConfig) getDomainStrategy() router.Config_DomainStrategy { @@ -81,6 +83,11 @@ func (c *RouterConfig) Build() (*router.Config, error) { if err != nil { return nil, err } + + if rule.DomainMatcher == "" { + rule.DomainMatcher = c.DomainMatcher + } + config.Rule = append(config.Rule, rule) } for _, rawBalancer := range c.Balancers {