1
0
Fork 0

Implemented func GatherStatus() to get a list of running services.

This commit is contained in:
Alexander Andreev 2023-02-05 05:13:19 +04:00
parent 1dc390a967
commit 9e2e490f4a
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F
1 changed files with 19 additions and 0 deletions

View File

@ -1,3 +1,22 @@
package servicestat
import (
"encoding/json"
"net/http"
)
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{}
r, err := cl.Do(rq)
if err != nil {
return lst, err
}
lst = make(ServiceList)
err = json.NewDecoder(r.Body).Decode(&lst)
return lst, err
}