1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-06-12 22:07:47 +02:00

Add client response

This commit is contained in:
Asim Aslam
2019-01-14 21:30:43 +00:00
parent f2ac73eae5
commit c1d0237370
8 changed files with 105 additions and 44 deletions

View File

@ -35,11 +35,17 @@ func (c *Codec) ReadBody(b interface{}) error {
}
func (c *Codec) Write(m *codec.Message, b interface{}) error {
v, ok := b.(*[]byte)
if !ok {
return fmt.Errorf("failed to write: %v is not type of *[]byte", b)
var v []byte
switch b.(type) {
case *[]byte:
ve := b.(*[]byte)
v = *ve
case []byte:
v = b.([]byte)
default:
return fmt.Errorf("failed to write: %v is not type of *[]byte or []byte", b)
}
_, err := c.Conn.Write(*v)
_, err := c.Conn.Write(v)
return err
}