Api App
This commit is contained in:
36
api.go
36
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",
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user