You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
consul/troubleshoot/utils.go

37 lines
689 B

package troubleshoot
import (
"context"
"fmt"
"io"
"net/http"
)
func (t *Troubleshoot) request(path string) ([]byte, error) {
client := &http.Client{}
url := fmt.Sprintf("http://%v:%s/%s", t.envoyAddr.IP, t.envoyAdminPort, path)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return nil, err
}
resp, err := client.Do(req.WithContext(context.Background()))
if err != nil {
return nil, err
}
if resp != nil {
defer resp.Body.Close()
}
if resp != nil && resp.StatusCode == http.StatusNotFound {
return nil, fmt.Errorf("ErrBackendNotMounted")
}
rawConfig, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
return rawConfig, nil
}