fasten-onprem/backend/pkg/web/middleware/server_sent_event.go

16 lines
374 B
Go

package middleware
import (
"github.com/gin-gonic/gin"
)
func SSEHeaderMiddleware() gin.HandlerFunc {
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()
}
}