Using sse.ContentType instead of hardcoded one

This commit is contained in:
Manu Mtz-Almeida 2015-05-13 23:24:56 +02:00
parent a8b9e2d8d6
commit 662a35d209

View File

@ -19,7 +19,7 @@ func (_ sseRender) Render(w http.ResponseWriter, code int, data ...interface{})
func WriteSSEvent(w http.ResponseWriter, eventName string, data interface{}) error { func WriteSSEvent(w http.ResponseWriter, eventName string, data interface{}) error {
header := w.Header() header := w.Header()
if len(header.Get("Content-Type")) == 0 { if len(header.Get("Content-Type")) == 0 {
header.Set("Content-Type", "text/event-stream") header.Set("Content-Type", sse.ContentType)
} }
return sse.Encode(w, sse.Event{ return sse.Encode(w, sse.Event{
Event: eventName, Event: eventName,