Merge pull request '[🚀] message' (#15) from dev into main
Reviewed-on: #15
This commit is contained in:
commit
0c6e90e644
@ -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