mirror of
https://github.com/songquanpeng/message-pusher.git
synced 2025-10-05 08:06:51 +08:00
feat: use sse to fetch new messages (close #70)
This commit is contained in:
13
middleware/sse.go
Normal file
13
middleware/sse.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package middleware
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
func SetSSEHeaders() func(c *gin.Context) {
|
||||
return func(c *gin.Context) {
|
||||
c.Writer.Header().Set("Content-Type", "text/event-stream")
|
||||
c.Writer.Header().Set("Cache-Control", "no-cache")
|
||||
c.Writer.Header().Set("Connection", "keep-alive")
|
||||
c.Writer.Header().Set("Transfer-Encoding", "chunked")
|
||||
c.Next()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user