1
0
dwelling-home/pkg/servicestat/list.go

24 lines
462 B
Go

package servicestat
import (
"encoding/json"
"net/http"
"time"
)
type ServiceList map[string]bool
func GatherStatus(url string) (lst ServiceList, err error) {
rq, _ := http.NewRequest(http.MethodGet, url, nil)
rq.Header.Set("Content-Type", "application/json")
cl := &http.Client{Timeout: 1 * time.Second}
r, err := cl.Do(rq)
if err != nil {
return lst, err
}
lst = make(ServiceList)
err = json.NewDecoder(r.Body).Decode(&lst)
return lst, err
}