dial connects to the websocket server
(token, url string)
| 137 | |
| 138 | // dial connects to the websocket server |
| 139 | func dial(token, url string) (*websocket.Conn, error) { |
| 140 | h := make(http.Header) |
| 141 | h.Set("Authorization", token) |
| 142 | c, resp, err := websocket.DefaultDialer.Dial(url, h) |
| 143 | if err != nil { |
| 144 | if resp != nil { |
| 145 | body, _ := io.ReadAll(resp.Body) |
| 146 | err = fmt.Errorf("code: %v - body: %s - err: %w", resp.StatusCode, body, err) |
| 147 | } |
| 148 | return nil, err |
| 149 | } |
| 150 | return c, nil |
| 151 | } |
| 152 | |
| 153 | type httpEventForward struct { |
| 154 | Status int |