7 "github.com/gin-gonic/gin"
8 common "github.com/iotbzh/xds-common/golib"
9 "github.com/iotbzh/xds-server/lib/xdsconfig"
12 var confMut sync.Mutex
14 // GetConfig returns server configuration
15 func (s *APIService) getConfig(c *gin.Context) {
17 defer confMut.Unlock()
19 c.JSON(http.StatusOK, s.cfg)
22 // SetConfig sets server configuration
23 func (s *APIService) setConfig(c *gin.Context) {
24 // FIXME - must be tested
25 c.JSON(http.StatusNotImplemented, "Not implemented")
27 var cfgArg xdsconfig.Config
29 if c.BindJSON(&cfgArg) != nil {
30 common.APIError(c, "Invalid arguments")
35 defer confMut.Unlock()
37 s.log.Debugln("SET config: ", cfgArg)
39 if err := s.mfolder.UpdateAll(cfgArg); err != nil {
40 common.APIError(c, err.Error())
44 c.JSON(http.StatusOK, s.cfg)