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,45 @@
package app
import (
"encoding/json"
"io"
"net/http"
)
func handleTransportSingBoxProfileRender(w http.ResponseWriter, r *http.Request, id string) {
if r.Method != http.MethodPost {
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
return
}
body, checkBinary, persist, err := decodeTransportSingBoxProfileRenderRequest(r)
if err != nil {
http.Error(w, "bad json", http.StatusBadRequest)
return
}
singBoxProfilesMu.Lock()
defer singBoxProfilesMu.Unlock()
status, resp := executeTransportSingBoxProfileRenderLocked(id, body, checkBinary, persist)
writeJSON(w, status, resp)
}
func decodeTransportSingBoxProfileRenderRequest(r *http.Request) (SingBoxProfileRenderRequest, bool, bool, error) {
var body SingBoxProfileRenderRequest
if r.Body != nil {
defer r.Body.Close()
if err := json.NewDecoder(io.LimitReader(r.Body, 1<<20)).Decode(&body); err != nil && err != io.EOF {
return SingBoxProfileRenderRequest{}, false, false, err
}
}
checkBinary := true
if body.CheckBinary != nil {
checkBinary = *body.CheckBinary
}
persist := true
if body.Persist != nil {
persist = *body.Persist
}
return body, checkBinary, persist, nil
}