-
Notifications
You must be signed in to change notification settings - Fork 1
/
options.go
55 lines (44 loc) · 1.78 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package handlers
import (
"fmt"
"net/http"
"github.com/byuoitav/common/log"
"github.com/byuoitav/shipwright/helpers"
"github.com/labstack/echo"
)
// GetIcons gets a list of possible icons to use
func GetIcons(context echo.Context) error {
log.L.Debugf("%s Starting GetIcons...", helpers.OptionsTag)
iconList, err := helpers.GetIcons()
if err != nil {
msg := fmt.Sprintf("failed to get icons from the database : %s", err.Error())
log.L.Errorf("%s %s", helpers.OptionsTag, msg)
return context.JSON(http.StatusInternalServerError, err)
}
log.L.Debugf("%s Successfully got the icons from the database!", helpers.OptionsTag)
return context.JSON(http.StatusOK, iconList)
}
// GetTemplates gets a list of possible templates to use
func GetTemplates(context echo.Context) error {
log.L.Debugf("%s Starting GetTemplates...", helpers.OptionsTag)
templateList, err := helpers.GetTemplates()
if err != nil {
msg := fmt.Sprintf("failed to get templates from the database : %s", err.Error())
log.L.Errorf("%s %s", helpers.OptionsTag, msg)
return context.JSON(http.StatusInternalServerError, err)
}
log.L.Debugf("%s Successfully got the templates from the database!", helpers.OptionsTag)
return context.JSON(http.StatusOK, templateList)
}
// GetMenuTree gets the fully built out menu tree
func GetMenuTree(context echo.Context) error {
log.L.Debugf("%s Starting GetMenuTree...", helpers.OptionsTag)
menuTree, err := helpers.GetMenuTree()
if err != nil {
msg := fmt.Sprintf("failed to get the menu tree from the database : %s", err.Error())
log.L.Errorf("%s %s", helpers.OptionsTag, msg)
return context.JSON(http.StatusInternalServerError, err)
}
log.L.Debugf("%s Successfully got the menu tree from the database!", helpers.OptionsTag)
return context.JSON(http.StatusOK, menuTree)
}