diff --git a/apps/backend/public/views/main.html b/apps/backend/public/views/main.html index daa91be..32f8af8 100644 --- a/apps/backend/public/views/main.html +++ b/apps/backend/public/views/main.html @@ -90,7 +90,7 @@
diff --git a/apps/backend/server.go b/apps/backend/server.go index 7df28c3..fee0d51 100644 --- a/apps/backend/server.go +++ b/apps/backend/server.go @@ -79,7 +79,15 @@ func (s *Server) SetupRoutes() *echo.Echo { }) e.GET("/health", func(c echo.Context) error { h := queries.HealthCheck() - return c.String(http.StatusOK, fmt.Sprintf("DB Connection: %v", h)) + + s_error := HealthCheckStorage() + var s string + if s_error != nil { + s = s_error.Error() + } else { + s = "OK" + } + return c.JSONPretty(http.StatusOK, fmt.Sprintf("DB Connection: %v, Storage Connection: %v", h, s), " ") }) // MIOGEST ROUTES diff --git a/apps/backend/storage.go b/apps/backend/storage.go index 3490e35..2b9d701 100644 --- a/apps/backend/storage.go +++ b/apps/backend/storage.go @@ -14,6 +14,18 @@ import ( "time" ) +func HealthCheckStorage() error { + resp, err := http.Get(config.Cfg.Storage.Endpoint + "/health") + if err != nil { + return fmt.Errorf("storage health check failed: %w", err) + } + defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { + return fmt.Errorf("storage health check failed: %s", resp.Status) + } + return nil +} + func DeleteFile(id string) error { req, err := http.NewRequest("DELETE", config.Cfg.Storage.Endpoint+"/delete/"+id+"?token="+config.Cfg.Storage.Token, nil) if err != nil {