IsWSHandshakeRequest returns true if the given request is a websocket handshake request.
(req *http.Request)
| 64 | |
| 65 | // IsWSHandshakeRequest returns true if the given request is a websocket handshake request. |
| 66 | func IsWSHandshakeRequest(req *http.Request) bool { |
| 67 | if strings.ToLower(req.Header.Get("Upgrade")) == "websocket" { |
| 68 | // Connection header values can be of form "foo, bar, ..." |
| 69 | parts := strings.Split(strings.ToLower(req.Header.Get("Connection")), ",") |
| 70 | for _, part := range parts { |
| 71 | if strings.TrimSpace(part) == "upgrade" { |
| 72 | return true |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | return false |
| 77 | } |
| 78 | |
| 79 | // Wrap implements middleware.Interface |
| 80 | func (i Instrument) Wrap(next http.Handler) http.Handler { |