This commit is contained in:
Ben Toogood 2020-04-07 11:24:13 +01:00
parent 76f6f80318
commit 05ac3ff274

View File

@ -141,10 +141,12 @@ func (h authHandler) NamespaceFromRequest(req *http.Request) string {
// determine the host, e.g. dev.micro.mu:8080 // determine the host, e.g. dev.micro.mu:8080
host := req.URL.Hostname() host := req.URL.Hostname()
if h, _, err := net.SplitHostPort(req.Host); err == nil { if len(host) == 0 {
host = h // host does contain a port if h, _, err := net.SplitHostPort(req.Host); err == nil {
} else if strings.Contains(err.Error(), "missing port in address") { host = h // host does contain a port
host = req.Host // host does not contain a port } else if strings.Contains(err.Error(), "missing port in address") {
host = req.Host // host does not contain a port
}
} }
// check for an ip address // check for an ip address