Support body rewrite
This commit is contained in:
@@ -87,16 +87,21 @@ func GetTimeout() int {
|
||||
return timeout
|
||||
}
|
||||
|
||||
func GetRewrites() map[string]string {
|
||||
func GetRewrites(hostMatch string) map[string]string {
|
||||
v := packable.NewString()
|
||||
conf.Get(nsConf, flagRewrites, v)
|
||||
m := make(map[string]string)
|
||||
for _, v := range strings.Split(v.String(), ",") {
|
||||
if len(v) == 0 {
|
||||
return m
|
||||
vs := strings.Split(v, ":")
|
||||
if len(v) < 3 {
|
||||
continue
|
||||
}
|
||||
from := v[:strings.Index(v, ":")]
|
||||
to := v[strings.Index(v, ":")+1:]
|
||||
host := vs[0]
|
||||
if host != hostMatch {
|
||||
continue
|
||||
}
|
||||
from := vs[1]
|
||||
to := strings.Join(vs[2:], ":")
|
||||
m[from] = to
|
||||
}
|
||||
return m
|
||||
|
||||
Reference in New Issue
Block a user