(ctx context.Context, msg string)
| 201 | } |
| 202 | |
| 203 | func (cl *client) publish(ctx context.Context, msg string) (err error) { |
| 204 | defer func() { |
| 205 | if err != nil { |
| 206 | cl.c.Close(websocket.StatusInternalError, "publish failed") |
| 207 | } |
| 208 | }() |
| 209 | |
| 210 | req, _ := http.NewRequestWithContext(ctx, http.MethodPost, cl.url+"/publish", strings.NewReader(msg)) |
| 211 | resp, err := http.DefaultClient.Do(req) |
| 212 | if err != nil { |
| 213 | return err |
| 214 | } |
| 215 | defer resp.Body.Close() |
| 216 | if resp.StatusCode != http.StatusAccepted { |
| 217 | return fmt.Errorf("publish request failed: %v", resp.StatusCode) |
| 218 | } |
| 219 | return nil |
| 220 | } |
| 221 | |
| 222 | func (cl *client) publishMsgs(ctx context.Context, msgs map[string]struct{}) error { |
| 223 | for m := range msgs { |
no test coverage detected