Fix text codec

This commit is contained in:
Asim Aslam 2019-06-10 12:42:43 +01:00
parent b6833e478d
commit 46de3ae9a9

View File

@ -30,6 +30,9 @@ func (c *Codec) ReadBody(b interface{}) error {
} }
switch b.(type) { switch b.(type) {
case *string:
v := b.(*string)
*v = string(buf)
case *[]byte: case *[]byte:
v := b.(*[]byte) v := b.(*[]byte)
*v = buf *v = buf
@ -51,6 +54,12 @@ func (c *Codec) Write(m *codec.Message, b interface{}) error {
case *[]byte: case *[]byte:
ve := b.(*[]byte) ve := b.(*[]byte)
v = *ve v = *ve
case *string:
ve := b.(*string)
v = []byte(*ve)
case string:
ve := b.(string)
v = []byte(ve)
case []byte: case []byte:
v = b.([]byte) v = b.([]byte)
default: default:
@ -65,7 +74,7 @@ func (c *Codec) Close() error {
} }
func (c *Codec) String() string { func (c *Codec) String() string {
return "bytes" return "text"
} }
func NewCodec(c io.ReadWriteCloser) codec.Codec { func NewCodec(c io.ReadWriteCloser) codec.Codec {