Check Remote API

This commit is contained in:
mr 2024-08-21 11:28:13 +02:00
parent 4693b96130
commit 01bbb9be2c

View File

@ -45,3 +45,18 @@ func (a *API) GetState() (State, int, error) {
}
return ALIVE, 200, nil
}
func (a *API) CheckRemoteAPIs(urls map[string]map[METHOD]string) (State, int, error) {
// Check if the database is up
caller := NewHTTPCaller(urls)
for _, methods := range urls {
if k, ok := methods[GET]; !ok {
return REDUCED_SERVICE, 200, errors.New("no get method found for " + k + " API")
}
_, err := caller.CallGet(methods[GET], "")
if err != nil {
return REDUCED_SERVICE, 200, err
}
}
return ALIVE, 200, nil
}