diff --git a/services/services.go b/services/services.go index d0ebd0cb34a5e9cb36f43817b3b51226544f5885..00a8476e20db50b20873b4f9bcc782de4b155460 100644 --- a/services/services.go +++ b/services/services.go @@ -75,16 +75,19 @@ func CalculateUniqueAuthors(books []models.GutenbergBook) int { return len(authorsSet) } -// CheckServiceAvailability checks the availability of a given service URL. -func CheckServiceAvailability(serviceURL string) string { +func CheckServiceAvailability(serviceURL string) int { resp, err := http.Get(serviceURL) if err != nil { - return "Unavailable" + // If there's an error, might want to return a status code indicating the service is unavailable + return http.StatusServiceUnavailable } defer resp.Body.Close() - return http.StatusText(resp.StatusCode) + + // Return the HTTP status code of the response + return resp.StatusCode } + // Assuming you have a global variable to track the start time of your service. var serviceStartTime = time.Now()