GOWA - WhatsApp REST API with support for UI, Multi Account, Webhooks, and MCP, and Chatwoot. Built with Golang for efficient memory use.
Go botgogolanggolang-whatsappgolang-whatsapp-apirestrest-apiwhatsappwhatsapp-apiwhatsapp-api-gowhatsapp-multi-devicewhatsapp-web-multi-device
feat: add healthcheck endpoint (#522)
Israel Schroeder Moreirafc7fe7bd1048
diff --git a/src/cmd/rest.go b/src/cmd/rest.goindex 0a2a5d5d..9825fefc 100644--- a/src/cmd/rest.go+++ b/src/cmd/rest.go@@ -76,9 +76,19 @@ func restServer(_ *cobra.Command, _ []string) {AllowHeaders: "Origin, Content-Type, Accept",}))- // Device manager - needed for chatwoot webhook+ // Device manager - needed for chatwoot webhook and health checkdm := whatsapp.GetDeviceManager()+ // Health check endpoint (public, no auth)+ // Registered at root path (ignoring AppBasePath) to ensure fixed availability+ // for infrastructure health probes (Kubernetes liveness/readiness, Docker healthcheck, etc.)+ app.Get("/health", func(c *fiber.Ctx) error {+ if dm != nil && dm.IsHealthy() {+ return c.SendString("OK")+ }+ return c.Status(http.StatusServiceUnavailable).SendString("Service Unavailable")+ })+// Chatwoot webhook - registered BEFORE basic auth middleware// This allows Chatwoot to send webhooks without authenticationif config.ChatwootEnabled {diff --git a/src/infrastructure/whatsapp/device_manager.go b/src/infrastructure/whatsapp/device_manager.goindex 2234978f..822e02f8 100644--- a/src/infrastructure/whatsapp/device_manager.go+++ b/src/infrastructure/whatsapp/device_manager.go@@ -69,6 +69,19 @@ func (m *DeviceManager) GetDevice(id string) (*DeviceInstance, bool) {return instance, ok}+// IsHealthy returns true if the device manager is initialized and has a valid store connection.+// Note: This is a service initialization check, not a live connectivity check.+// Returning true indicates the internal store is ready, but does not guarantee+// that any WhatsApp device connections are currently active or authenticated.+func (m *DeviceManager) IsHealthy() bool {+ if m == nil {+ return false+ }+ m.mu.RLock()+ defer m.mu.RUnlock()+ return m.store != nil+}+// DefaultDevice returns the only registered device when running in single-device mode.func (m *DeviceManager) DefaultDevice() *DeviceInstance {if m == nil {