I have this function:
func GetBasicAuth(w http.ResponseWriter, r *http.Request) (string, error) {
secret, _, ok := r.BasicAuth()
if !ok {
return "", err //is this right?
}
return secret, nil
}
I've had to declare that the function will return a string and an error but in reality it will return one or the other. If the BasicAuth function wasn't ok
then I have no string to return so what do I do here - just send an empty string? This seems weird!