Refit source files to have a public xs-apiv1 lib package.
[src/xds/xds-server.git] / lib / xdsserver / apiv1-config.go
1 package xdsserver
2
3 import (
4         "net/http"
5         "sync"
6
7         "github.com/gin-gonic/gin"
8         common "github.com/iotbzh/xds-common/golib"
9         "github.com/iotbzh/xds-server/lib/xsapiv1"
10 )
11
12 var confMut sync.Mutex
13
14 // GetConfig returns server configuration
15 func (s *APIService) getConfig(c *gin.Context) {
16         confMut.Lock()
17         defer confMut.Unlock()
18
19         c.JSON(http.StatusOK, s.Config)
20 }
21
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")
26
27         var cfgArg xsapiv1.APIConfig
28
29         if c.BindJSON(&cfgArg) != nil {
30                 common.APIError(c, "Invalid arguments")
31                 return
32         }
33
34         confMut.Lock()
35         defer confMut.Unlock()
36
37         s.Log.Debugln("SET config: ", cfgArg)
38
39         common.APIError(c, "Not Supported")
40 }