aboutsummaryrefslogtreecommitdiffstats
path: root/lib/apiv1/folders.go
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-11-06 14:50:03 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-11-06 16:00:04 +0100
commitebf38065f8a0c0c3d1a3a7ce2a4caaaad712432c (patch)
tree00ca89c63f4ce48566202c6c32f76fe1ad3de4d3 /lib/apiv1/folders.go
parent8d3f51e52894d46a4a92a944bc09f4ceaa1abf51 (diff)
Added short project ID name support if not ambiguous.
Diffstat (limited to 'lib/apiv1/folders.go')
-rw-r--r--lib/apiv1/folders.go22
1 files changed, 17 insertions, 5 deletions
diff --git a/lib/apiv1/folders.go b/lib/apiv1/folders.go
index a231b86..398e21c 100644
--- a/lib/apiv1/folders.go
+++ b/lib/apiv1/folders.go
@@ -16,7 +16,12 @@ func (s *APIService) getFolders(c *gin.Context) {
// getFolder returns a specific folder configuration
func (s *APIService) getFolder(c *gin.Context) {
- f := s.mfolders.Get(c.Param("id"))
+ id, err := s.mfolders.ResolveID(c.Param("id"))
+ if err != nil {
+ common.APIError(c, err.Error())
+ return
+ }
+ f := s.mfolders.Get(id)
if f == nil {
common.APIError(c, "Invalid id")
return
@@ -67,11 +72,14 @@ func (s *APIService) addFolder(c *gin.Context) {
// syncFolder force synchronization of folder files
func (s *APIService) syncFolder(c *gin.Context) {
- id := c.Param("id")
-
+ id, err := s.mfolders.ResolveID(c.Param("id"))
+ if err != nil {
+ common.APIError(c, err.Error())
+ return
+ }
s.log.Debugln("Sync folder id: ", id)
- err := s.mfolders.ForceSync(id)
+ err = s.mfolders.ForceSync(id)
if err != nil {
common.APIError(c, err.Error())
return
@@ -82,7 +90,11 @@ func (s *APIService) syncFolder(c *gin.Context) {
// delFolder deletes folder from server config
func (s *APIService) delFolder(c *gin.Context) {
- id := c.Param("id")
+ id, err := s.mfolders.ResolveID(c.Param("id"))
+ if err != nil {
+ common.APIError(c, err.Error())
+ return
+ }
s.log.Debugln("Delete folder id ", id)