Support body rewrite

This commit is contained in:
Bel LaPointe
2019-04-10 10:47:30 -06:00
parent f72ecc5e53
commit f58f6f7cf3
4 changed files with 71 additions and 11 deletions

View File

@@ -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