passes tests with no rewrites

This commit is contained in:
Bel LaPointe
2019-04-10 10:08:47 -06:00
parent 3bd1527b98
commit f72ecc5e53
3 changed files with 78 additions and 7 deletions

View File

@@ -23,6 +23,7 @@ const flagPass = "pass"
const flagRate = "rate"
const flagBurst = "burst"
const flagTimeout = "timeout"
const flagRewrites = "rw"
var conf = storage.NewMap()
@@ -41,6 +42,7 @@ type fileConf struct {
Rate string `yaml:"rate"`
Burst string `yaml:"burst"`
Timeout string `yaml:"timeout"`
Rewrites []string `yaml:"rw"`
}
func Init() error {
@@ -100,6 +102,9 @@ func fromFile() error {
if err := conf.Set(nsConf, flagTimeout, packable.NewString(c.Timeout)); err != nil {
return err
}
if err := conf.Set(nsConf, flagRewrites, packable.NewString(strings.Join(c.Rewrites, ","))); err != nil {
return err
}
return nil
}
@@ -115,6 +120,7 @@ func fromFlags() error {
binds = append(binds, addFlag(flagRate, "100", "rate limit per second"))
binds = append(binds, addFlag(flagBurst, "100", "rate limit burst"))
binds = append(binds, addFlag(flagTimeout, "30", "seconds to wait for limiter"))
binds = append(binds, addFlag(flagRewrites, "", "comma-separated regex:v to rewrite in response bodies"))
flag.Parse()
for _, bind := range binds {