Exemple #1
0
func convertPayload(in interface{}, out interface{}) error {
	var buf []byte
	if err := codec.NewEncoderBytes(&buf, payloadHandler).Encode(in); err != nil {
		return err
	}
	if err := codec.NewDecoderBytes(buf, payloadHandler).Decode(out); err != nil {
		return err
	}
	return nil
}
Exemple #2
0
// WriteHead converts the HTTP status code and the headers to the cocaine format
func WriteHead(code int, headers Headers) []byte {
	var out []byte
	codec.NewEncoderBytes(&out, h).Encode([]interface{}{code, headers})
	return out
}