Priority/backend/priority.go
2023-12-14 16:54:05 +01:00

37 lines
672 B
Go

package main
import (
"log"
"net/http"
"github.com/gin-gonic/gin"
)
// ///////// Priority
func (w *Webapp) GetPriority(c *gin.Context) {
log.Printf("send priority %s", w.Stream.StatusPriority)
c.JSON(http.StatusOK, w.Stream.StatusPriority)
}
func (w *Webapp) SetPriority(c *gin.Context) {
var msg Message
var err error
log.Printf("set priority %s", c.Request.Body)
err = c.ShouldBind(&msg)
if err != nil {
log.Printf("req error: %+v", err)
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, "OK")
log.Printf("msg %+v", msg)
w.Stream.StatusPriority = msg.Priority
w.Stream.SendPriority(msg.Priority)
}