diff options
Diffstat (limited to 'lib/apiv1')
-rw-r--r-- | lib/apiv1/apiv1.go | 7 | ||||
-rw-r--r-- | lib/apiv1/config.go | 2 | ||||
-rw-r--r-- | lib/apiv1/exec.go | 2 | ||||
-rw-r--r-- | lib/apiv1/folders.go | 4 | ||||
-rw-r--r-- | lib/apiv1/make.go | 2 |
5 files changed, 10 insertions, 7 deletions
diff --git a/lib/apiv1/apiv1.go b/lib/apiv1/apiv1.go index 56c7503..c94849d 100644 --- a/lib/apiv1/apiv1.go +++ b/lib/apiv1/apiv1.go @@ -4,6 +4,7 @@ import ( "github.com/Sirupsen/logrus" "github.com/gin-gonic/gin" + "github.com/iotbzh/xds-server/lib/model" "github.com/iotbzh/xds-server/lib/session" "github.com/iotbzh/xds-server/lib/xdsconfig" ) @@ -13,17 +14,19 @@ type APIService struct { router *gin.Engine apiRouter *gin.RouterGroup sessions *session.Sessions - cfg xdsconfig.Config + cfg *xdsconfig.Config + mfolder *model.Folder log *logrus.Logger } // New creates a new instance of API service -func New(sess *session.Sessions, cfg xdsconfig.Config, r *gin.Engine) *APIService { +func New(sess *session.Sessions, cfg *xdsconfig.Config, mfolder *model.Folder, r *gin.Engine) *APIService { s := &APIService{ router: r, sessions: sess, apiRouter: r.Group("/api/v1"), cfg: cfg, + mfolder: mfolder, log: cfg.Log, } diff --git a/lib/apiv1/config.go b/lib/apiv1/config.go index a2817a0..326b6fa 100644 --- a/lib/apiv1/config.go +++ b/lib/apiv1/config.go @@ -36,7 +36,7 @@ func (s *APIService) setConfig(c *gin.Context) { s.log.Debugln("SET config: ", cfgArg) - if err := s.cfg.UpdateAll(cfgArg); err != nil { + if err := s.mfolder.UpdateAll(cfgArg); err != nil { common.APIError(c, err.Error()) return } diff --git a/lib/apiv1/exec.go b/lib/apiv1/exec.go index b0bfd41..18fdc7e 100644 --- a/lib/apiv1/exec.go +++ b/lib/apiv1/exec.go @@ -75,7 +75,7 @@ func (s *APIService) execCmd(c *gin.Context) { return } - prj := s.cfg.GetFolderFromID(id) + prj := s.mfolder.GetFolderFromID(id) if prj == nil { common.APIError(c, "Unknown id") return diff --git a/lib/apiv1/folders.go b/lib/apiv1/folders.go index b1864a2..b4d2ac0 100644 --- a/lib/apiv1/folders.go +++ b/lib/apiv1/folders.go @@ -44,7 +44,7 @@ func (s *APIService) addFolder(c *gin.Context) { s.log.Debugln("Add folder config: ", cfgArg) - newFld, err := s.cfg.UpdateFolder(cfgArg) + newFld, err := s.mfolder.UpdateFolder(cfgArg) if err != nil { common.APIError(c, err.Error()) return @@ -68,7 +68,7 @@ func (s *APIService) delFolder(c *gin.Context) { var delEntry xdsconfig.FolderConfig var err error - if delEntry, err = s.cfg.DeleteFolder(id); err != nil { + if delEntry, err = s.mfolder.DeleteFolder(id); err != nil { common.APIError(c, err.Error()) return } diff --git a/lib/apiv1/make.go b/lib/apiv1/make.go index 9596e13..0f7561f 100644 --- a/lib/apiv1/make.go +++ b/lib/apiv1/make.go @@ -72,7 +72,7 @@ func (s *APIService) buildMake(c *gin.Context) { return } - prj := s.cfg.GetFolderFromID(id) + prj := s.mfolder.GetFolderFromID(id) if prj == nil { common.APIError(c, "Unknown id") return |