Merge pull request '[🚀] message' (#15) from dev into main

Reviewed-on: #15
This commit is contained in:
bvbej 2024-09-07 16:00:42 +08:00
commit 0c6e90e644

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("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)