From 25e0620a3fbae2e54ec670ab18ad77eb79795b8b Mon Sep 17 00:00:00 2001 From: zyj <18107291228@163.com> Date: Tue, 16 Sep 2025 17:54:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9websockt=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E9=89=B4=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/websocks.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api/websocks.go b/api/websocks.go index 39632b5..afd5c8d 100644 --- a/api/websocks.go +++ b/api/websocks.go @@ -35,7 +35,7 @@ func (*Websocks) Init(ctx *gin.Context) { // 判断当前连接是否合法 key := http.CanonicalHeaderKey("sec-websocket-protocol") protos := ctx.Request.Header[key] - if len(protos) > 0 { + if len(protos) <= 0 { ctx.JSON(http.StatusInternalServerError, gin.H{"code": WebsocktFailed.Code, "data": WebsocktFailed.Data, "msg": WebsocktFailed.Msg}) return } @@ -60,7 +60,6 @@ func (*Websocks) Init(ctx *gin.Context) { if err != nil { log.Printf("WebSocket 升级失败: %v", err) - ctx.JSON(http.StatusInternalServerError, gin.H{"code": WebsocktFailed.Code, "data": WebsocktFailed.Data, "msg": WebsocktFailed.Msg}) return }