[🚀] message

This commit is contained in:
bvbej 2024-09-07 16:00:30 +08:00
parent ad1e06229f
commit 3d5a4a1482

View File

@ -90,6 +90,10 @@ func (stream *event) HandlerFunc() mux.HandlerFunc {
c.Context().Writer.Header().Set("Connection", "keep-alive")
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 {
if msg, ok := <-e; ok {
c.Context().SSEvent(msg.Name, msg.Message)