platform: modularize api/gui, add docs-tests-web foundation, and refresh root config

This commit is contained in:
beckline
2026-03-26 22:40:54 +03:00
parent 0e2d7f61ea
commit 6a56d734c2
562 changed files with 70151 additions and 16423 deletions

View File

@@ -0,0 +1,46 @@
package app
import (
"net/http"
"strconv"
"strings"
)
func handleTransportSingBoxProfileHistory(w http.ResponseWriter, r *http.Request, id string) {
if r.Method != http.MethodGet {
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
return
}
limit := 50
if s := strings.TrimSpace(r.URL.Query().Get("limit")); s != "" {
if n, err := strconv.Atoi(s); err == nil && n > 0 {
if n > 500 {
n = 500
}
limit = n
}
}
records, err := loadSingBoxHistoryRecords(id, limit)
if err != nil {
writeJSON(w, http.StatusInternalServerError, SingBoxProfileHistoryResponse{
OK: false,
Code: singBoxProfileCodeRollbackFailed,
Message: "history read failed: " + err.Error(),
ProfileID: id,
})
return
}
items := make([]SingBoxProfileHistoryEntry, 0, len(records))
for _, it := range records {
items = append(items, it.Public())
}
writeJSON(w, http.StatusOK, SingBoxProfileHistoryResponse{
OK: true,
Message: "ok",
ProfileID: id,
Count: len(items),
Items: items,
})
}