config: add option to disable panel config updates (#162)

This commit is contained in:
Jakob Schrettenbrunner
2023-02-27 21:05:36 +01:00
committed by GitHub
parent 4d9fee383f
commit ec6d6d83ea
2 changed files with 18 additions and 1 deletions

View File

@@ -113,9 +113,21 @@ func postCreateServer(c *gin.Context) {
c.Status(http.StatusAccepted)
}
type postUpdateConfigurationResponse struct {
Applied bool `json:"applied"`
}
// Updates the running configuration for this Wings instance.
func postUpdateConfiguration(c *gin.Context) {
cfg := config.Get()
if cfg.IgnorePanelConfigUpdates {
c.JSON(http.StatusOK, postUpdateConfigurationResponse{
Applied: false,
})
return
}
if err := c.BindJSON(&cfg); err != nil {
return
}
@@ -139,5 +151,7 @@ func postUpdateConfiguration(c *gin.Context) {
// Since we wrote it to the disk successfully now update the global configuration
// state to use this new configuration struct.
config.Set(cfg)
c.Status(http.StatusNoContent)
c.JSON(http.StatusOK, postUpdateConfigurationResponse{
Applied: true,
})
}