I'm trying to develop something like simple chat.
func watch(rw http.ResponseWriter, r render.Render) {
var msg string
ok := true
for ok {
select {
case msg, ok = <-Ct.Msgs:
rw.Write([]byte(msg))
fmt.Printf("Wrote: %v", msg)
f, ok := rw.(http.Flusher)
if ok {
f.Flush()
fmt.Println("Flushed")
} else {
r.JSON(http.StatusOK, Response{"status": "error", "descr": "CANT_FLUSH"})
return
}
}
}
r.JSON(http.StatusOK, Response{"status": "ok", "descr": "finished"})
}
But I see nothing in my browser.