forked from pneymrl2f/nightingale
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
395 B
25 lines
395 B
package sse
|
|
|
|
import "io"
|
|
|
|
type stringWriter interface {
|
|
io.Writer
|
|
WriteString(string) (int, error)
|
|
}
|
|
|
|
type stringWrapper struct {
|
|
io.Writer
|
|
}
|
|
|
|
func (w stringWrapper) WriteString(str string) (int, error) {
|
|
return w.Writer.Write([]byte(str))
|
|
}
|
|
|
|
func checkWriter(writer io.Writer) stringWriter {
|
|
if w, ok := writer.(stringWriter); ok {
|
|
return w
|
|
} else {
|
|
return stringWrapper{writer}
|
|
}
|
|
}
|