implement new json_data model
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
json_dataModels "github.com/tecamino/tecamino-json_data/models"
|
||||
)
|
||||
|
||||
// sends a list of all buses in the driver
|
||||
@@ -79,17 +80,16 @@ func (d *ArtNetDriver) RemoveBus(c *gin.Context) {
|
||||
}
|
||||
|
||||
if _, ok := d.Buses[payload.Name]; !ok {
|
||||
c.JSON(http.StatusOK, gin.H{"message": "bus " + payload.Name + " not found"})
|
||||
c.JSON(http.StatusOK, models.JsonResponse{
|
||||
Message: "bus " + payload.Name + " not found"})
|
||||
r := json_dataModels.NewResponse()
|
||||
r.SendMessage("bus " + payload.Name + " not found")
|
||||
c.JSON(http.StatusOK, r)
|
||||
return
|
||||
} else {
|
||||
delete(d.Buses, payload.Name)
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, models.JsonResponse{
|
||||
Message: fmt.Sprintf("bus '%s' successfully removed", payload.Name),
|
||||
})
|
||||
r := json_dataModels.NewResponse()
|
||||
r.SendMessage(fmt.Sprintf("bus '%s' successfully removed", payload.Name))
|
||||
c.JSON(http.StatusOK, r)
|
||||
d.cfgHandler.SaveCfg(*d)
|
||||
}
|
||||
|
||||
@@ -114,9 +114,9 @@ func (d *ArtNetDriver) Start(c *gin.Context) {
|
||||
|
||||
d.Buses[payload.Name].Start(d.Log)
|
||||
|
||||
c.JSON(http.StatusOK, models.JsonResponse{
|
||||
Message: fmt.Sprintf("bus '%s' running", payload.Name),
|
||||
})
|
||||
r := json_dataModels.NewResponse()
|
||||
r.SendMessage(fmt.Sprintf("bus '%s' running", payload.Name))
|
||||
c.JSON(http.StatusOK, r)
|
||||
d.cfgHandler.SaveCfg(*d)
|
||||
}
|
||||
|
||||
@@ -141,8 +141,8 @@ func (d *ArtNetDriver) Stop(c *gin.Context) {
|
||||
|
||||
d.Buses[payload.Name].Stop()
|
||||
|
||||
c.JSON(http.StatusOK, models.JsonResponse{
|
||||
Message: fmt.Sprintf("bus '%s' stopped", payload.Name),
|
||||
})
|
||||
r := json_dataModels.NewResponse()
|
||||
r.SendMessage(fmt.Sprintf("bus '%s' stopped", payload.Name))
|
||||
c.JSON(http.StatusOK, r)
|
||||
d.cfgHandler.SaveCfg(*d)
|
||||
}
|
||||
|
Reference in New Issue
Block a user