29bc79996b
Settings are loaded from the DB and added to the AppConfig during startup. When updating settings, they are stored in AppConfig, and written do the database.
26 lines
604 B
Go
26 lines
604 B
Go
package handler
|
|
|
|
import (
|
|
"github.com/analogj/scrutiny/webapp/backend/pkg/database"
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/sirupsen/logrus"
|
|
"net/http"
|
|
)
|
|
|
|
func GetSettings(c *gin.Context) {
|
|
logger := c.MustGet("LOGGER").(logrus.FieldLogger)
|
|
deviceRepo := c.MustGet("DEVICE_REPOSITORY").(database.DeviceRepo)
|
|
|
|
settings, err := deviceRepo.LoadSettings(c)
|
|
if err != nil {
|
|
logger.Errorln("An error occurred while retrieving settings", err)
|
|
c.JSON(http.StatusInternalServerError, gin.H{"success": false})
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"success": true,
|
|
"settings": settings,
|
|
})
|
|
}
|