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