package weblive import ( "net/http" "strings" "github.com/gin-gonic/gin" ) func GetLiveModeration(c *gin.Context) { c.JSON(http.StatusOK, ModerationStateSnapshot()) } func PutLiveMuteAll(c *gin.Context) { var body struct { Enabled bool `json:"enabled"` } if err := c.ShouldBindJSON(&body); err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": "参数无效"}) return } SetMuteAll(body.Enabled) c.JSON(http.StatusOK, gin.H{"ok": true}) } func PutLiveMuteIP(c *gin.Context) { var body struct { IP string `json:"ip"` Enabled bool `json:"enabled"` } if err := c.ShouldBindJSON(&body); err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": "参数无效"}) return } ip := strings.TrimSpace(body.IP) if ip == "" { c.JSON(http.StatusBadRequest, gin.H{"error": "IP 不能为空"}) return } SetIPMuted(ip, body.Enabled) c.JSON(http.StatusOK, gin.H{"ok": true}) }