Skip to content

Commit

Permalink
Merge 687bc47 into f170fa3
Browse files Browse the repository at this point in the history
  • Loading branch information
kpacha committed Feb 11, 2019
2 parents f170fa3 + 687bc47 commit 4926fb6
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion config/config.go
Expand Up @@ -239,6 +239,19 @@ type TLS struct {
// ExtraConfig is a type to store extra configurations for customized behaviours
type ExtraConfig map[string]interface{}

func (e *ExtraConfig) sanitize() {
for module, extra := range *e {
switch extra := extra.(type) {
case map[interface{}]interface{}:
sanitized := map[string]interface{}{}
for k, v := range extra {
sanitized[fmt.Sprintf("%v", k)] = v
}
(*e)[module] = sanitized
}
}
}

// ConfigGetter is a function for parsing ExtraConfig into a previously know type
type ConfigGetter func(ExtraConfig) interface{}

Expand Down Expand Up @@ -291,6 +304,8 @@ func (s *ServiceConfig) Init() error {

s.Host = s.uriParser.CleanHosts(s.Host)

s.ExtraConfig.sanitize()

for i, e := range s.Endpoints {
e.Endpoint = s.uriParser.CleanPath(e.Endpoint)

Expand All @@ -312,12 +327,16 @@ func (s *ServiceConfig) Init() error {
return errInvalidNoOpEncoding
}

for j := range e.Backend {
e.ExtraConfig.sanitize()

for j, b := range e.Backend {
s.initBackendDefaults(i, j)

if err := s.initBackendURLMappings(i, j, inputSet); err != nil {
return err
}

b.ExtraConfig.sanitize()
}
}

Expand Down

0 comments on commit 4926fb6

Please sign in to comment.