修改websockt服务鉴权
This commit is contained in:
@@ -35,7 +35,7 @@ func (*Websocks) Init(ctx *gin.Context) {
|
|||||||
// 判断当前连接是否合法
|
// 判断当前连接是否合法
|
||||||
key := http.CanonicalHeaderKey("sec-websocket-protocol")
|
key := http.CanonicalHeaderKey("sec-websocket-protocol")
|
||||||
protos := ctx.Request.Header[key]
|
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})
|
ctx.JSON(http.StatusInternalServerError, gin.H{"code": WebsocktFailed.Code, "data": WebsocktFailed.Data, "msg": WebsocktFailed.Msg})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,6 @@ func (*Websocks) Init(ctx *gin.Context) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("WebSocket 升级失败: %v", err)
|
log.Printf("WebSocket 升级失败: %v", err)
|
||||||
|
|
||||||
ctx.JSON(http.StatusInternalServerError, gin.H{"code": WebsocktFailed.Code, "data": WebsocktFailed.Data, "msg": WebsocktFailed.Msg})
|
ctx.JSON(http.StatusInternalServerError, gin.H{"code": WebsocktFailed.Code, "data": WebsocktFailed.Data, "msg": WebsocktFailed.Msg})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user