29 lines
480 B
Go
29 lines
480 B
Go
package response
|
|
|
|
import (
|
|
"encoding/binary"
|
|
)
|
|
|
|
type V0Response struct {
|
|
header V0Header
|
|
body []byte
|
|
}
|
|
|
|
func NewV0Reponse(correlation_id uint32) *V0Response {
|
|
return &V0Response{
|
|
header: V0Header{
|
|
Correlation_id: correlation_id},
|
|
body: []byte{},
|
|
}
|
|
}
|
|
|
|
func (r *V0Response) ToBytes() []byte {
|
|
header := r.header.ToBytes()
|
|
length := len(header)
|
|
buf := make([]byte, length+4)
|
|
binary.BigEndian.PutUint32(buf[0:4], uint32(length))
|
|
copy(buf[4:], header)
|
|
|
|
return buf
|
|
}
|