options: gracefully report un-parsed upstream URL

upstreamURL is a nil pointer if there is an error parsing --upstream
This commit is contained in:
Pierce Lopez 2017-08-05 12:48:36 -04:00
parent 3c51c914ac
commit e9bbecface

View File

@ -142,14 +142,13 @@ func (o *Options) Validate() error {
for _, u := range o.Upstreams {
upstreamURL, err := url.Parse(u)
if err != nil {
msgs = append(msgs, fmt.Sprintf(
"error parsing upstream=%q %s",
upstreamURL, err))
msgs = append(msgs, fmt.Sprintf("error parsing upstream: %s", err))
} else {
if upstreamURL.Path == "" {
upstreamURL.Path = "/"
}
o.proxyURLs = append(o.proxyURLs, upstreamURL)
}
if upstreamURL.Path == "" {
upstreamURL.Path = "/"
}
o.proxyURLs = append(o.proxyURLs, upstreamURL)
}
for _, u := range o.SkipAuthRegex {