IsWebsocket returns true if the request headers indicate that a websocket handshake is being initiated by the client.
()
| 1040 | // IsWebsocket returns true if the request headers indicate that a websocket |
| 1041 | // handshake is being initiated by the client. |
| 1042 | func (c *Context) IsWebsocket() bool { |
| 1043 | if strings.Contains(strings.ToLower(c.requestHeader("Connection")), "upgrade") && |
| 1044 | strings.EqualFold(c.requestHeader("Upgrade"), "websocket") { |
| 1045 | return true |
| 1046 | } |
| 1047 | return false |
| 1048 | } |
| 1049 | |
| 1050 | func (c *Context) requestHeader(key string) string { |
| 1051 | return c.Request.Header.Get(key) |