Code Review
/
src
/
xds
/
xds-agent.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Moved Dashboad webapp on Angular 5 !
[src/xds/xds-agent.git]
/
lib
/
agent
/
apiv1-projects.go
diff --git
a/lib/agent/apiv1-projects.go
b/lib/agent/apiv1-projects.go
index
d4b5e74
..
c835967
100644
(file)
--- a/
lib/agent/apiv1-projects.go
+++ b/
lib/agent/apiv1-projects.go
@@
-4,6
+4,7
@@
import (
"net/http"
"github.com/gin-gonic/gin"
"net/http"
"github.com/gin-gonic/gin"
+ "github.com/iotbzh/xds-agent/lib/apiv1"
common "github.com/iotbzh/xds-common/golib"
)
common "github.com/iotbzh/xds-common/golib"
)
@@
-14,7
+15,12
@@
func (s *APIService) getProjects(c *gin.Context) {
// getProject returns a specific project configuration
func (s *APIService) getProject(c *gin.Context) {
// getProject returns a specific project configuration
func (s *APIService) getProject(c *gin.Context) {
- prj := s.projects.Get(c.Param("id"))
+ id, err := s.projects.ResolveID(c.Param("id"))
+ if err != nil {
+ common.APIError(c, err.Error())
+ return
+ }
+ prj := s.projects.Get(id)
if prj == nil {
common.APIError(c, "Invalid id")
return
if prj == nil {
common.APIError(c, "Invalid id")
return
@@
-25,7
+31,7
@@
func (s *APIService) getProject(c *gin.Context) {
// addProject adds a new project to server config
func (s *APIService) addProject(c *gin.Context) {
// addProject adds a new project to server config
func (s *APIService) addProject(c *gin.Context) {
- var cfgArg ProjectConfig
+ var cfgArg
apiv1.
ProjectConfig
if c.BindJSON(&cfgArg) != nil {
common.APIError(c, "Invalid arguments")
return
if c.BindJSON(&cfgArg) != nil {
common.APIError(c, "Invalid arguments")
return
@@
-44,22
+50,30
@@
func (s *APIService) addProject(c *gin.Context) {
// syncProject force synchronization of project files
func (s *APIService) syncProject(c *gin.Context) {
// syncProject force synchronization of project files
func (s *APIService) syncProject(c *gin.Context) {
- id := c.Param("id")
+ id, err := s.projects.ResolveID(c.Param("id"))
+ if err != nil {
+ common.APIError(c, err.Error())
+ return
+ }
s.Log.Debugln("Sync project id: ", id)
s.Log.Debugln("Sync project id: ", id)
- err
:
= s.projects.ForceSync(id)
+ err = s.projects.ForceSync(id)
if err != nil {
common.APIError(c, err.Error())
return
}
if err != nil {
common.APIError(c, err.Error())
return
}
- c.JSON(http.StatusOK,
""
)
+ c.JSON(http.StatusOK,
nil
)
}
// delProject deletes project from server config
func (s *APIService) delProject(c *gin.Context) {
}
// delProject deletes project from server config
func (s *APIService) delProject(c *gin.Context) {
- id := c.Param("id")
+ id, err := s.projects.ResolveID(c.Param("id"))
+ if err != nil {
+ common.APIError(c, err.Error())
+ return
+ }
s.Log.Debugln("Delete project id ", id)
s.Log.Debugln("Delete project id ", id)