This commit is contained in:
shoopea
2025-12-27 19:35:54 +01:00
parent a1ba422429
commit 3e867da45f
3 changed files with 40 additions and 8 deletions

36
api.go
View File

@@ -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",
})
}