mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-12 10:55:51 +02:00
refactor: cache index
This commit is contained in:
parent
5d8d96fd4f
commit
269397e114
20 changed files with 532 additions and 364 deletions
|
@ -16,6 +16,8 @@ import (
|
|||
"github.com/uozi-tech/cosy/logger"
|
||||
)
|
||||
|
||||
// getLogPath resolves the log file path based on the provided control parameters
|
||||
// It checks if the path is under the whitelist directories
|
||||
func getLogPath(control *controlStruct) (logPath string, err error) {
|
||||
// If direct log path is provided, use it
|
||||
if control.LogPath != "" {
|
||||
|
@ -58,6 +60,7 @@ func getLogPath(control *controlStruct) (logPath string, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// tailNginxLog tails the specified log file and sends each line to the websocket
|
||||
func tailNginxLog(ws *websocket.Conn, controlChan chan controlStruct, errChan chan error) {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
|
@ -130,6 +133,7 @@ func tailNginxLog(ws *websocket.Conn, controlChan chan controlStruct, errChan ch
|
|||
}
|
||||
}
|
||||
|
||||
// handleLogControl processes websocket control messages
|
||||
func handleLogControl(ws *websocket.Conn, controlChan chan controlStruct, errChan chan error) {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
|
@ -160,6 +164,7 @@ func handleLogControl(ws *websocket.Conn, controlChan chan controlStruct, errCha
|
|||
}
|
||||
}
|
||||
|
||||
// Log handles websocket connection for real-time log viewing
|
||||
func Log(c *gin.Context) {
|
||||
var upGrader = websocket.Upgrader{
|
||||
CheckOrigin: func(r *http.Request) bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue