///ESM推送 func RevMsgHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/event-stream") w.Header().Set("Cache-Control", "no-cache") fileHelper := new(lib.FileHelper) data, err := fileHelper.ReadFile("./nsqconsumer/data.txt") if err != nil { data = "data load failed" } msg := "data:" + data + "\n\n" io.WriteString(w, msg) }
func saveMsg(msg models.Messages) error { fileHelper := new(lib.FileHelper) return fileHelper.WriteFile("data.txt", msg.Message) }