Significant improvements to attaching/console handling
This commit is contained in:
21
server/console.go
Normal file
21
server/console.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package server
|
||||
|
||||
import "io"
|
||||
|
||||
type Console struct {
|
||||
Server *Server
|
||||
HandlerFunc *func(string)
|
||||
}
|
||||
|
||||
var _ io.Writer = Console{}
|
||||
|
||||
func (c Console) Write(b []byte) (int, error) {
|
||||
if c.HandlerFunc != nil {
|
||||
l := make([]byte, len(b))
|
||||
copy(l, b)
|
||||
|
||||
(*c.HandlerFunc)(string(l))
|
||||
}
|
||||
|
||||
return len(b), nil
|
||||
}
|
||||
Reference in New Issue
Block a user