新增 WebSocket 网关:连接管理、心跳保活、限流与消息路由

This commit is contained in:
2026-09-27 19:26:55 +08:00
parent ff9add8655
commit 99d1827262
11 changed files with 632 additions and 8 deletions
+4
View File
@@ -5,6 +5,7 @@ import (
"git.lzcwy.cn/zhengchiliu/zt-online-game-backend/internal/middleware"
v1 "git.lzcwy.cn/zhengchiliu/zt-online-game-backend/internal/routers/api/v1"
"git.lzcwy.cn/zhengchiliu/zt-online-game-backend/internal/wsgateway"
"github.com/gin-gonic/gin"
)
@@ -25,6 +26,9 @@ func NewRouter() *gin.Engine {
c.JSON(http.StatusOK, gin.H{"message": "pong"})
})
// WebSocket 建连入口:必须放在鉴权组之外,token 走 query 由 ServeWS 自行校验。
r.GET("/ws", wsgateway.ServeWS)
// handler 实例
userHandler := v1.NewUserHandler()