2023-02-05 04:48:39 +04:00
|
|
|
package servicestat
|
|
|
|
|
2023-02-05 05:13:19 +04:00
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"net/http"
|
2023-12-16 04:27:03 +04:00
|
|
|
"time"
|
2023-02-05 05:13:19 +04:00
|
|
|
)
|
|
|
|
|
2023-02-05 04:48:39 +04:00
|
|
|
type ServiceList map[string]bool
|
2023-02-05 05:13:19 +04:00
|
|
|
|
|
|
|
func GatherStatus(url string) (lst ServiceList, err error) {
|
|
|
|
rq, _ := http.NewRequest(http.MethodGet, url, nil)
|
|
|
|
rq.Header.Set("Content-Type", "application/json")
|
|
|
|
|
2023-12-16 04:27:03 +04:00
|
|
|
cl := &http.Client{Timeout: 1 * time.Second}
|
2023-02-05 05:13:19 +04:00
|
|
|
r, err := cl.Do(rq)
|
|
|
|
if err != nil {
|
|
|
|
return lst, err
|
|
|
|
}
|
|
|
|
lst = make(ServiceList)
|
|
|
|
err = json.NewDecoder(r.Body).Decode(&lst)
|
|
|
|
return lst, err
|
|
|
|
}
|