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,15 +142,14 @@ func (o *Options) Validate() error {
for _, u := range o.Upstreams { for _, u := range o.Upstreams {
upstreamURL, err := url.Parse(u) upstreamURL, err := url.Parse(u)
if err != nil { if err != nil {
msgs = append(msgs, fmt.Sprintf( msgs = append(msgs, fmt.Sprintf("error parsing upstream: %s", err))
"error parsing upstream=%q %s", } else {
upstreamURL, err))
}
if upstreamURL.Path == "" { if upstreamURL.Path == "" {
upstreamURL.Path = "/" upstreamURL.Path = "/"
} }
o.proxyURLs = append(o.proxyURLs, upstreamURL) o.proxyURLs = append(o.proxyURLs, upstreamURL)
} }
}
for _, u := range o.SkipAuthRegex { for _, u := range o.SkipAuthRegex {
CompiledRegex, err := regexp.Compile(u) CompiledRegex, err := regexp.Compile(u)