(c *gin.Context, str string)
| 62 | } |
| 63 | |
| 64 | func StringData(c *gin.Context, str string) error { |
| 65 | //str = strings.TrimPrefix(str, "data: ") |
| 66 | //str = strings.TrimSuffix(str, "\r") |
| 67 | c.Render(-1, common.CustomEvent{Data: "data: " + str}) |
| 68 | if flusher, ok := c.Writer.(http.Flusher); ok { |
| 69 | flusher.Flush() |
| 70 | } else { |
| 71 | return errors.New("streaming error: flusher not found") |
| 72 | } |
| 73 | return nil |
| 74 | } |
| 75 | |
| 76 | func PingData(c *gin.Context) error { |
| 77 | c.Writer.Write([]byte(": PING\n\n")) |
no test coverage detected