1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-24 10:07:04 +02:00

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