mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
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:
@@ -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})
|
||||
|
||||
Reference in New Issue
Block a user