Skip to content

Commit

Permalink
feat(self-check): check websocket
Browse files Browse the repository at this point in the history
  • Loading branch information
0xJacky committed Jan 23, 2025
1 parent 5c11266 commit 132e05c
Showing 17 changed files with 203 additions and 294 deletions.
1 change: 1 addition & 0 deletions api/system/router.go
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ func InitPrivateRouter(r *gin.RouterGroup) {
r.GET("upgrade/current", GetCurrentVersion)
r.GET("self_check", SelfCheck)
r.POST("self_check/:name/fix", SelfCheckFix)
r.GET("self_check/websocket", CheckWebSocket)
}

func InitWebSocketRouter(r *gin.RouterGroup) {
23 changes: 23 additions & 0 deletions api/system/self_check.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package system

import (
"github.com/gorilla/websocket"
"github.com/uozi-tech/cosy/logger"
"net/http"

"github.com/0xJacky/Nginx-UI/internal/self_check"
@@ -16,3 +18,24 @@ func SelfCheckFix(c *gin.Context) {
result := self_check.AttemptFix(c.Param("name"))
c.JSON(http.StatusOK, result)
}

func CheckWebSocket(c *gin.Context) {
var upgrader = websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool {
return true
},
}
ws, err := upgrader.Upgrade(c.Writer, c.Request, nil)
if err != nil {
logger.Error(err)
return
}
defer ws.Close()
err = ws.WriteJSON(gin.H{
"message": "ok",
})
if err != nil {
logger.Error(err)
return
}
}
1 change: 0 additions & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -72,7 +72,6 @@
"eslint-plugin-sonarjs": "^3.0.1",
"less": "^4.2.1",
"postcss": "^8.5.1",
"tailwindcss": "^3.4.17",
"typescript": "5.7.3",
"unplugin-auto-import": "^19.0.0",
"unplugin-vue-components": "^28.0.0",
Loading

0 comments on commit 132e05c

Please sign in to comment.