telemetry server: add optional https and authentication

This commit is contained in:
Nicola Murino
2020-12-18 16:04:42 +01:00
parent 140380716d
commit bcf0fa073e
21 changed files with 492 additions and 169 deletions

View File

@@ -46,10 +46,10 @@ func sendHTTPRequest(method, url string, body io.Reader, contentType string) (*h
if err != nil {
return nil, err
}
if len(contentType) > 0 {
if contentType != "" {
req.Header.Set("Content-Type", "application/json")
}
if len(authUsername) > 0 || len(authPassword) > 0 {
if authUsername != "" || authPassword != "" {
req.SetBasicAuth(authUsername, authPassword)
}
return httpclient.GetHTTPClient().Do(req)