Add a little more resiliency for differently formed URLs

This commit is contained in:
Tristan Weir 2018-12-17 16:14:29 -08:00
Родитель bf615806b0
Коммит bb6cf19a19
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 1C5E6CBF4E06FB04
1 изменённых файлов: 8 добавлений и 3 удалений

Просмотреть файл

@ -16,6 +16,7 @@ import (
"log" "log"
"net" "net"
"net/http" "net/http"
"net/url"
"os" "os"
"strings" "strings"
"time" "time"
@ -312,10 +313,14 @@ func GetAuthToken() (string, error) {
// load them into a searchable map, keyed to asset hostname // load them into a searchable map, keyed to asset hostname
// the ServiceAPI object must already be loaded with a Bearer token // the ServiceAPI object must already be loaded with a Bearer token
func GetAssets(m map[string]ServiceApiAsset) error { func GetAssets(m map[string]ServiceApiAsset) error {
// get json array of assets from serviceapi // get json array of assets from serviceapi
requestURL := conf.ServiceApi.URL + "api/v1/assets/" requestURL, err := url.Parse(conf.ServiceApi.URL)
req, err := http.NewRequest(http.MethodGet, requestURL, nil) if err != nil {
return err
}
requestURL.Path = "api/v1/assets/"
req, err := http.NewRequest(http.MethodGet, requestURL.String(), nil)
if err != nil { if err != nil {
return err return err
} }