ref(helm): clean up callService

pull/404/head
Michelle Noorali 9 years ago
parent 899dc0b225
commit 17143feb87

@ -91,14 +91,17 @@ func NewClient(c *cli.Context) *client.Client {
func callService(path, method, description string) ([]byte, error) {
dmURL := "http://localhost:8080"
//dmURL := "http://localhost:8001/api/v1/proxy/namespaces/dm/services/manager-service:manager"
var URL *url.URL
URL, err := url.Parse(dmURL)
//TODO: dmURL := "http://localhost:8001/api/v1/proxy/namespaces/dm/services/manager-service:manager"
client := &http.Client{}
url, err := formatPath(dmURL, path)
req, err := http.NewRequest(method, url.Path, nil)
if err != nil {
return nil, err
}
resp, err := client.Do(req)
if err != nil {
return nil, err
}
URL.Path = strings.TrimRight(URL.String(), "/") + "/" + strings.TrimLeft(path, "/")
resp, err := http.Get(URL.Path) //TODO: change later
if err != nil {
return nil, err
}
@ -110,3 +113,13 @@ func callService(path, method, description string) ([]byte, error) {
}
return body, nil
}
func formatPath(rawURL, route string) (*url.URL, error) {
var URL *url.URL
URL, err := url.Parse(rawURL)
if err != nil {
return nil, err
}
URL.Path = strings.TrimRight(URL.String(), "/") + "/" + strings.TrimLeft(route, "/")
return URL, nil
}

Loading…
Cancel
Save