diff options
author | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-11-29 08:54:00 +0100 |
---|---|---|
committer | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-11-29 11:10:30 +0100 |
commit | 2f7828d01f4c4ca2909f95f098627cd5475ed225 (patch) | |
tree | b5e71920b813b95cae3e32044be08b99223348ec /lib/xdsserver/apiv1-config.go | |
parent | 5caebfb4b7c3b73988f067082b219ce5b7f409ba (diff) |
Refit source files to have a public xs-apiv1 lib package.
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'lib/xdsserver/apiv1-config.go')
-rw-r--r-- | lib/xdsserver/apiv1-config.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/xdsserver/apiv1-config.go b/lib/xdsserver/apiv1-config.go new file mode 100644 index 0000000..5a5bb6e --- /dev/null +++ b/lib/xdsserver/apiv1-config.go @@ -0,0 +1,40 @@ +package xdsserver + +import ( + "net/http" + "sync" + + "github.com/gin-gonic/gin" + common "github.com/iotbzh/xds-common/golib" + "github.com/iotbzh/xds-server/lib/xsapiv1" +) + +var confMut sync.Mutex + +// GetConfig returns server configuration +func (s *APIService) getConfig(c *gin.Context) { + confMut.Lock() + defer confMut.Unlock() + + c.JSON(http.StatusOK, s.Config) +} + +// SetConfig sets server configuration +func (s *APIService) setConfig(c *gin.Context) { + // FIXME - must be tested + c.JSON(http.StatusNotImplemented, "Not implemented") + + var cfgArg xsapiv1.APIConfig + + if c.BindJSON(&cfgArg) != nil { + common.APIError(c, "Invalid arguments") + return + } + + confMut.Lock() + defer confMut.Unlock() + + s.Log.Debugln("SET config: ", cfgArg) + + common.APIError(c, "Not Supported") +} |