2023-12-05 13:48:13 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
2023-12-14 16:54:05 +01:00
|
|
|
// ///////// Priority
|
2023-12-05 13:48:13 +01:00
|
|
|
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)
|
|
|
|
}
|