add new lights, add login and role to it, add services page

This commit is contained in:
Adrian Zuercher
2025-08-09 18:00:36 +02:00
parent 7d2ab814da
commit 1697a4dcfd
56 changed files with 1337 additions and 290 deletions

View File

@@ -0,0 +1,36 @@
package drivers
import (
"backend/models"
"encoding/json"
"net/http"
"os"
"github.com/gin-gonic/gin"
)
type DriverHandler struct {
driversConfig string
}
func NewDriverHandler(cfgDir string) *DriverHandler {
return &DriverHandler{driversConfig: cfgDir}
}
func (dH *DriverHandler) GetDriverList(c *gin.Context) {
content, err := os.ReadFile(dH.driversConfig)
if err != nil {
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
return
}
var data struct {
Drivers []models.Drivers `json:"drivers"`
}
err = json.Unmarshal(content, &data)
if err != nil {
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
return
}
c.JSON(http.StatusOK, data.Drivers)
}