feat: implement local dev packet capture functionality with admin endpoints and configurable limits for debugging.

This commit is contained in:
CJACK
2026-02-20 03:46:15 +08:00
parent dec9d03fc5
commit 541816f2ab
8 changed files with 449 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
package admin
import (
"net/http"
"ds2api/internal/devcapture"
)
func (h *Handler) getDevCaptures(w http.ResponseWriter, _ *http.Request) {
store := devcapture.Global()
writeJSON(w, http.StatusOK, map[string]any{
"enabled": store.Enabled(),
"limit": store.Limit(),
"max_body_bytes": store.MaxBodyBytes(),
"items": store.Snapshot(),
})
}
func (h *Handler) clearDevCaptures(w http.ResponseWriter, _ *http.Request) {
store := devcapture.Global()
store.Clear()
writeJSON(w, http.StatusOK, map[string]any{
"success": true,
"detail": "capture logs cleared",
})
}