...

Source file src/github.com/gin-contrib/sse/writer.go

Documentation: github.com/gin-contrib/sse

     1  package sse
     2  
     3  import "io"
     4  
     5  type stringWriter interface {
     6  	io.Writer
     7  	WriteString(string) (int, error)
     8  }
     9  
    10  type stringWrapper struct {
    11  	io.Writer
    12  }
    13  
    14  func (w stringWrapper) WriteString(str string) (int, error) {
    15  	return w.Writer.Write([]byte(str))
    16  }
    17  
    18  func checkWriter(writer io.Writer) stringWriter {
    19  	if w, ok := writer.(stringWriter); ok {
    20  		return w
    21  	} else {
    22  		return stringWrapper{writer}
    23  	}
    24  }
    25  

View as plain text