diff --git a/admin.go b/admin.go index 8a028f1..2e08e3f 100644 --- a/admin.go +++ b/admin.go @@ -61,6 +61,10 @@ func (a *AdminConfig) Run() { r.GET("/config", ApiConfig) r.GET("/config/:app", ApiConfigApp) + r.GET("/app/list", ApiAppList) + r.GET("/app/add/:app", ApiAppAdd) + r.GET("/app/del/:app", ApiAppDel) + srv := &http.Server{ Addr: a.Addr, Handler: r, diff --git a/api.go b/api.go index 990500d..2379825 100644 --- a/api.go +++ b/api.go @@ -1,10 +1,12 @@ package main import ( + "encoding/json" "net/http" "time" "github.com/gin-gonic/gin" + "github.com/tidwall/pretty" ) func ApiRun(c *gin.Context) { @@ -68,10 +70,6 @@ func ApiSnapshotList(c *gin.Context) { "error": "no app found", }) } - c.JSON(http.StatusInternalServerError, gin.H{ - "message": "error", - "error": "not implemented", - }) } func ApiScheduleAdd(c *gin.Context) { @@ -162,3 +160,33 @@ func ApiConfigApp(c *gin.Context) { }) } } + +func ApiAppList(c *gin.Context) { + list := make([]string, 0) + for _, app := range cfg.apps { + list = append(list, app.name) + } + b, err := json.Marshal(list) + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{ + "message": "error", + "error": err, + }) + return + } + c.Data(http.StatusOK, "application/json", pretty.PrettyOptions(b, &pretty.Options{Indent: " "})) +} + +func ApiAppAdd(c *gin.Context) { + c.JSON(http.StatusInternalServerError, gin.H{ + "message": "error", + "error": "not implemented", + }) +} + +func ApiAppDel(c *gin.Context) { + c.JSON(http.StatusInternalServerError, gin.H{ + "message": "error", + "error": "not implemented", + }) +} diff --git a/version.go b/version.go index 09c0704..909f4f6 100644 --- a/version.go +++ b/version.go @@ -1,7 +1,7 @@ // Code generated by version.sh (@generated) DO NOT EDIT. package main -var githash = "05054be" +var githash = "a1ba422" var branch = "master" -var buildstamp = "2025-10-26_09:32:26" -var commits = "116" -var version = "05054be-b116 - 2025-10-26_09:32:26" +var buildstamp = "2025-12-27_18:34:17" +var commits = "117" +var version = "a1ba422-b117 - 2025-12-27_18:34:17"