From 01bbb9be2c98b5aa49805f9681490231f560028d Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 21 Aug 2024 11:28:13 +0200 Subject: [PATCH] Check Remote API --- tools/api.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/api.go b/tools/api.go index 475c4d9..2563550 100644 --- a/tools/api.go +++ b/tools/api.go @@ -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 +}