package middleware import ( "net/http" "music-server/internal/logging" "github.com/labstack/echo/v5" ) // SyncCheck blocks requests with HTTP 423 Locked while a sync is in progress. func SyncCheck(isSyncing func() bool) echo.MiddlewareFunc { return func(next echo.HandlerFunc) echo.HandlerFunc { return func(c *echo.Context) error { if isSyncing() { logging.GetLogger().Info("Syncing is in progress - request blocked") return echo.NewHTTPError(http.StatusLocked, "Syncing is in progress") } return next(c) } } }