aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/manucorporat/sse/writer.go
diff options
context:
space:
mode:
authorVidhu Kant Sharma <bokuwakanojogahoshii@yahoo.com>2020-10-19 11:05:36 +0530
committerVidhu Kant Sharma <bokuwakanojogahoshii@yahoo.com>2020-10-19 11:05:36 +0530
commit9c2ad91230d72fe6d661450cc78300ea223ae2bc (patch)
tree17bd774b3f972359dfbb46248f085bbf1c6dae98 /vendor/github.com/manucorporat/sse/writer.go
make it better
Diffstat (limited to 'vendor/github.com/manucorporat/sse/writer.go')
-rw-r--r--vendor/github.com/manucorporat/sse/writer.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/vendor/github.com/manucorporat/sse/writer.go b/vendor/github.com/manucorporat/sse/writer.go
new file mode 100644
index 0000000..6f9806c
--- /dev/null
+++ b/vendor/github.com/manucorporat/sse/writer.go
@@ -0,0 +1,24 @@
+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}
+ }
+}