func (r *Request) MarshalBody(
	assert audit.Assertion,
	contentType string,
	data interface{},
) *Request {
	switch contentType {
	case ApplicationGOB:
		body := &bytes.Buffer{}
		enc := gob.NewEncoder(body)
		err := enc.Encode(data)
		assert.Nil(err, "cannot encode data to GOB")
		r.Body = body.Bytes()
		r.AddHeader(HeaderContentType, ApplicationGOB)
		r.AddHeader(HeaderAccept, ApplicationGOB)
	case ApplicationJSON:
		body, err := json.Marshal(data)
		assert.Nil(err, "cannot marshal data to JSON")
		r.Body = body
		r.AddHeader(HeaderContentType, ApplicationJSON)
		r.AddHeader(HeaderAccept, ApplicationJSON)
	case ApplicationXML:
		body, err := xml.Marshal(data)
		assert.Nil(err, "cannot marshal data to XML")
		r.Body = body
		r.AddHeader(HeaderContentType, ApplicationXML)
		r.AddHeader(HeaderAccept, ApplicationXML)
	}
	return r
}
// MarshalBody sets the request body based on the type and
// the marshalled data.
MarshalBody sets the request body based on the type and
the marshalled data.
// MarshalBody sets the request body based on the type and // the marshalled data .
func (r *Request) MarshalBody(
	assert audit.Assertion,
	contentType string,
	data interface{},
) *Request {
	switch contentType {
	case ApplicationGOB:
		body := &bytes.Buffer{}
		enc := gob.NewEncoder(body)
		err := enc.Encode(data)
		assert.Nil(err, "cannot encode data to GOB")
		r.Body = body.Bytes()
		r.AddHeader(HeaderContentType, ApplicationGOB)
		r.AddHeader(HeaderAccept, ApplicationGOB)
	case ApplicationJSON:
		body, err := json.Marshal(data)
		assert.Nil(err, "cannot marshal data to JSON")
		r.Body = body
		r.AddHeader(HeaderContentType, ApplicationJSON)
		r.AddHeader(HeaderAccept, ApplicationJSON)
	case ApplicationXML:
		body, err := xml.Marshal(data)
		assert.Nil(err, "cannot marshal data to XML")
		r.Body = body
		r.AddHeader(HeaderContentType, ApplicationXML)
		r.AddHeader(HeaderAccept, ApplicationXML)
	}
	return r
}
func ( r * Request ) MarshalBody ( assert audit . Assertion , contentType string , data interface { } , ) * Request { switch contentType { case ApplicationGOB : body := & bytes . Buffer { } enc := gob . NewEncoder ( body ) err := enc . Encode ( data ) assert . Nil ( err , " " ) r . Body = body . Bytes ( ) r . AddHeader ( HeaderContentType , ApplicationGOB ) r . AddHeader ( HeaderAccept , ApplicationGOB ) case ApplicationJSON : body , err := json . Marshal ( data ) assert . Nil ( err , " " ) r . Body = body r . AddHeader ( HeaderContentType , ApplicationJSON ) r . AddHeader ( HeaderAccept , ApplicationJSON ) case ApplicationXML : body , err := xml . Marshal ( data ) assert . Nil ( err , " " ) r . Body = body r . AddHeader ( HeaderContentType , ApplicationXML ) r . AddHeader ( HeaderAccept , ApplicationXML ) } return r }
MarshalBody sets the request body based on the type and
the marshalled data.
MarshalBody sets the request body based on the type and the marshalled data .