const binaryWebSocketProtocol … const base64BinaryWebSocketProtocol … type ReaderProtocolConfig … // NewDefaultReaderProtocols returns a stream protocol map with the // subprotocols "", "channel.k8s.io", "base64.channel.k8s.io". func NewDefaultReaderProtocols() map[string]ReaderProtocolConfig { … } type Reader … // NewReader creates a WebSocket pipe that will copy the contents of r to a provided // WebSocket connection. If ping is true, a zero length message will be sent to the client // before the stream begins reading. // // The protocols parameter maps subprotocol names to StreamProtocols. The empty string // subprotocol name is used if websocket.Config.Protocol is empty. func NewReader(r io.Reader, ping bool, protocols map[string]ReaderProtocolConfig) *Reader { … } // SetIdleTimeout sets the interval for both reads and writes before timeout. If not specified, // there is no timeout on the reader. func (r *Reader) SetIdleTimeout(duration time.Duration) { … } func (r *Reader) handshake(config *websocket.Config, req *http.Request) error { … } // Copy the reader to the response. The created WebSocket is closed after this // method completes. func (r *Reader) Copy(w http.ResponseWriter, req *http.Request) error { … } // handle implements a WebSocket handler. func (r *Reader) handle(ws *websocket.Conn) { … } func resetTimeout(ws *websocket.Conn, timeout time.Duration) { … } func messageCopy(ws *websocket.Conn, r io.Reader, base64Encode, ping bool, timeout time.Duration) error { … }