[🚀] message
This commit is contained in:
parent
ad1e06229f
commit
3d5a4a1482
@ -90,6 +90,10 @@ func (stream *event) HandlerFunc() mux.HandlerFunc {
|
|||||||
c.Context().Writer.Header().Set("Connection", "keep-alive")
|
c.Context().Writer.Header().Set("Connection", "keep-alive")
|
||||||
c.Context().Writer.Header().Set("Transfer-Encoding", "chunked")
|
c.Context().Writer.Header().Set("Transfer-Encoding", "chunked")
|
||||||
|
|
||||||
|
time.AfterFunc(time.Second, func() {
|
||||||
|
e <- msgChan{Name: "message", Message: "success"}
|
||||||
|
})
|
||||||
|
|
||||||
c.Context().Stream(func(w io.Writer) bool {
|
c.Context().Stream(func(w io.Writer) bool {
|
||||||
if msg, ok := <-e; ok {
|
if msg, ok := <-e; ok {
|
||||||
c.Context().SSEvent(msg.Name, msg.Message)
|
c.Context().SSEvent(msg.Name, msg.Message)
|
||||||
|
Loading…
Reference in New Issue
Block a user