Files
wonderwall/pkg/config/ingress.go
Kent Daleng 8ee87a8a84 get ingresses from naiserator to build router correctly
Co-Authored-By: Trong Huu Nguyen <trong.huu.nguyen@nav.no>
Co-Authored-By: Kim Tore Jensen <kim.tore.jensen@nav.no>
2021-08-25 13:15:26 +02:00

29 lines
487 B
Go

package config
import (
"net/url"
"strings"
)
func ParseIngresses(ingresses []string) []string {
prefixMap := make(map[string]interface{})
for _, ingress := range ingresses {
ingressURL, err := url.Parse(ingress)
if err != nil {
continue
}
path := ingressURL.Path
path = strings.TrimRight(path, "/")
prefixMap[path] = new(interface{})
}
prefixes := make([]string, 0)
for prefix := range prefixMap {
prefixes = append(prefixes, prefix)
}
return prefixes
}