This commit is contained in:
laodaming 2023-08-24 11:38:42 +08:00
parent 6a45b1e1e7
commit 724b842167

View File

@ -84,7 +84,10 @@ type wsConnectItem struct {
func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) {
//把子协议携带的token设置到标准token头信息中
token := r.Header.Get("Sec-Websocket-Protocol")
r.Header.Set("Authorization", "Bearer "+token)
//有token是正常用户无则是白板用户也可以连接
if token != "" {
r.Header.Set("Authorization", "Bearer "+token)
}
//设置Sec-Websocket-Protocol
upgrader.Subprotocols = []string{token}
//升级websocket