Add dynamic log level adjustment and "type" field to auth files response

- Introduced `SetLogLevel` utility function for unified log level management.
- Updated dynamic log level handling across server and watcher components.
- Extended auth files response by extracting and including the `type` field from file content.
- Updated management API documentation with the new `type` field in auth files response.
This commit is contained in:
Luis Pater
2025-09-08 01:09:39 +08:00
parent 46fa32f087
commit c875088be2
8 changed files with 49 additions and 14 deletions

View File

@@ -8,6 +8,7 @@ import (
"strings"
"github.com/gin-gonic/gin"
"github.com/tidwall/gjson"
)
// List auth files
@@ -27,7 +28,16 @@ func (h *Handler) ListAuthFiles(c *gin.Context) {
continue
}
if info, errInfo := e.Info(); errInfo == nil {
files = append(files, gin.H{"name": name, "size": info.Size(), "modtime": info.ModTime()})
fileData := gin.H{"name": name, "size": info.Size(), "modtime": info.ModTime()}
// Read file to get type field
full := filepath.Join(h.cfg.AuthDir, name)
if data, errRead := os.ReadFile(full); errRead == nil {
typeValue := gjson.GetBytes(data, "type").String()
fileData["type"] = typeValue
}
files = append(files, fileData)
}
}
c.JSON(200, gin.H{"files": files})