fix: WriteContentType panic
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
type stringWriter interface {
|
type stringWriter interface {
|
||||||
@@ -52,6 +53,8 @@ type CustomEvent struct {
|
|||||||
Id string
|
Id string
|
||||||
Retry uint
|
Retry uint
|
||||||
Data interface{}
|
Data interface{}
|
||||||
|
|
||||||
|
Mutex sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func encode(writer io.Writer, event CustomEvent) error {
|
func encode(writer io.Writer, event CustomEvent) error {
|
||||||
@@ -73,6 +76,8 @@ func (r CustomEvent) Render(w http.ResponseWriter) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r CustomEvent) WriteContentType(w http.ResponseWriter) {
|
func (r CustomEvent) WriteContentType(w http.ResponseWriter) {
|
||||||
|
r.Mutex.Lock()
|
||||||
|
defer r.Mutex.Unlock()
|
||||||
header := w.Header()
|
header := w.Header()
|
||||||
header["Content-Type"] = contentType
|
header["Content-Type"] = contentType
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user