如何在 Go 中获取 socket.io 握手查询

How to get socket.io handshake query in Go

我们使用 go-socket.io package 到 运行 套接字服务器,我们需要使用握手查询数据对用户进行身份验证。 在 node.js 中,我们使用了如下代码:

authDataString = socket.handshake.query.authData;

我们需要在 Go 中做类似的事情。

您可以使用 socket to get query parameters from the request URL using FormValueRequest 字段:

    log.Print(socket.Request().FormValue("foo"))