WriteJsonData marshals data to JSON and queues it for writing
(data interface{})
| 275 | |
| 276 | // WriteJsonData marshals data to JSON and queues it for writing |
| 277 | func (h *SSEHandlerCh) WriteJsonData(data interface{}) error { |
| 278 | jsonData, err := json.Marshal(data) |
| 279 | if err != nil { |
| 280 | return fmt.Errorf("failed to marshal JSON: %v", err) |
| 281 | } |
| 282 | return h.WriteData(string(jsonData)) |
| 283 | } |
| 284 | |
| 285 | // WriteError queues an error message and closes the handler |
| 286 | func (h *SSEHandlerCh) WriteError(errorMsg string) error { |
no test coverage detected