package middleware import ( "log/slog" "git.mchus.pro/mchus/priceforge/internal/db" "github.com/gin-gonic/gin" ) // OfflineDetector creates middleware that detects offline mode // Sets context values: // - "is_offline" (bool) - true if MariaDB is unavailable func OfflineDetector(connMgr *db.ConnectionManager) gin.HandlerFunc { return func(c *gin.Context) { isOffline := !connMgr.IsOnline() // Set context values for handlers c.Set("is_offline", isOffline) if isOffline { slog.Debug("offline mode detected - MariaDB unavailable") } c.Next() } }