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,52 @@
package app
import (
"net/http"
"strings"
)
func handleTransportSingBoxProfileByID(w http.ResponseWriter, r *http.Request) {
const prefix = "/api/v1/transport/singbox/profiles/"
rest := strings.TrimPrefix(r.URL.Path, prefix)
if rest == "" || rest == r.URL.Path {
http.NotFound(w, r)
return
}
parts := strings.Split(strings.Trim(rest, "/"), "/")
if len(parts) == 0 || strings.TrimSpace(parts[0]) == "" {
http.NotFound(w, r)
return
}
id := sanitizeID(parts[0])
if id == "" {
writeJSON(w, http.StatusBadRequest, SingBoxProfilesResponse{
OK: false,
Code: singBoxProfileCodeBadID,
Message: "invalid profile id",
})
return
}
if len(parts) == 1 {
handleTransportSingBoxProfileCard(w, r, id)
return
}
if len(parts) > 2 {
http.NotFound(w, r)
return
}
action := strings.ToLower(strings.TrimSpace(parts[1]))
handleTransportSingBoxProfileAction(w, r, id, action)
}
func handleTransportSingBoxProfileCard(w http.ResponseWriter, r *http.Request, id string) {
switch r.Method {
case http.MethodGet:
handleTransportSingBoxProfileCardGet(w, r, id)
case http.MethodPatch:
handleTransportSingBoxProfileCardPatch(w, r, id)
case http.MethodDelete:
handleTransportSingBoxProfileCardDelete(w, r, id)
default:
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
}
}