|
@@ -8,6 +8,7 @@ import (
|
|
|
"github.com/SongZihuan/huan-proxy/src/config/rulescompile/actioncompile/filecompile"
|
|
|
"github.com/SongZihuan/huan-proxy/src/config/rulescompile/actioncompile/redirectcompile"
|
|
|
"github.com/SongZihuan/huan-proxy/src/config/rulescompile/actioncompile/remotetrustcompile"
|
|
|
+ "github.com/SongZihuan/huan-proxy/src/config/rulescompile/actioncompile/respheadercompile"
|
|
|
"github.com/SongZihuan/huan-proxy/src/config/rulescompile/matchcompile"
|
|
|
)
|
|
|
|
|
@@ -42,6 +43,8 @@ type RuleCompileConfig struct {
|
|
|
Dir *dircompile.RuleDirCompileConfig
|
|
|
Api *apicompile.RuleAPICompileConfig
|
|
|
Redirect *redirectcompile.RuleRedirectCompileConfig
|
|
|
+
|
|
|
+ RespHeader *respheadercompile.SetRespHeaderCompileConfig
|
|
|
}
|
|
|
|
|
|
func NewRuleCompileConfig(r *rules.RuleConfig) (*RuleCompileConfig, error) {
|
|
@@ -60,6 +63,11 @@ func NewRuleCompileConfig(r *rules.RuleConfig) (*RuleCompileConfig, error) {
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
+ respHeader, err := respheadercompile.NewSetRespHeaderCompileConfig(&r.RespHeader)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+
|
|
|
if typeID == ProxyTypeFile {
|
|
|
file, err := filecompile.NewRuleFileCompileConfig(&r.File)
|
|
|
if err != nil {
|
|
@@ -71,6 +79,7 @@ func NewRuleCompileConfig(r *rules.RuleConfig) (*RuleCompileConfig, error) {
|
|
|
MatchCompileConfig: match,
|
|
|
RemoteTrustCompileConfig: remoteTrusts,
|
|
|
File: file,
|
|
|
+ RespHeader: respHeader,
|
|
|
}, nil
|
|
|
} else if typeID == ProxyTypeDir {
|
|
|
dir, err := dircompile.NewRuleDirCompileConfig(&r.Dir)
|
|
@@ -83,6 +92,7 @@ func NewRuleCompileConfig(r *rules.RuleConfig) (*RuleCompileConfig, error) {
|
|
|
MatchCompileConfig: match,
|
|
|
RemoteTrustCompileConfig: remoteTrusts,
|
|
|
Dir: dir,
|
|
|
+ RespHeader: respHeader,
|
|
|
}, nil
|
|
|
} else if typeID == ProxyTypeAPI {
|
|
|
api, err := apicompile.NewRuleAPICompileConfig(&r.Api)
|
|
@@ -95,6 +105,7 @@ func NewRuleCompileConfig(r *rules.RuleConfig) (*RuleCompileConfig, error) {
|
|
|
MatchCompileConfig: match,
|
|
|
RemoteTrustCompileConfig: remoteTrusts,
|
|
|
Api: api,
|
|
|
+ RespHeader: respHeader,
|
|
|
}, nil
|
|
|
} else if typeID == ProxyTypeRedirect {
|
|
|
redirect, err := redirectcompile.NewRuleAPICompileConfig(&r.Redirect)
|
|
@@ -107,6 +118,7 @@ func NewRuleCompileConfig(r *rules.RuleConfig) (*RuleCompileConfig, error) {
|
|
|
MatchCompileConfig: match,
|
|
|
RemoteTrustCompileConfig: remoteTrusts,
|
|
|
Redirect: redirect,
|
|
|
+ RespHeader: respHeader,
|
|
|
}, nil
|
|
|
} else {
|
|
|
return nil, fmt.Errorf("error rule type")
|