func (p *Parameters) body() (io.Reader, error) {
	buffer := bytes.NewBuffer(nil)
	if p.Content == nil {
		return buffer, nil
	}
	// Process content based on content type.
	switch p.ContentType {
	case rest.ContentTypeXML:
		tmp, err := xml.Marshal(p.Content)
		if err != nil {
			return nil, errors.Annotate(err, ErrProcessingRequestContent, errorMessages)
		}
		buffer.Write(tmp)
	case rest.ContentTypeJSON:
		tmp, err := json.Marshal(p.Content)
		if err != nil {
			return nil, errors.Annotate(err, ErrProcessingRequestContent, errorMessages)
		}
		buffer.Write(tmp)
	case rest.ContentTypeGOB:
		enc := gob.NewEncoder(buffer)
		if err := enc.Encode(p.Content); err != nil {
			return nil, errors.Annotate(err, ErrProcessingRequestContent, errorMessages)
		}
	case rest.ContentTypeURLEncoded:
		values, err := p.values()
		if err != nil {
			return nil, err
		}
		_, err = buffer.WriteString(values.Encode())
		if err != nil {
			return nil, errors.Annotate(err, ErrProcessingRequestContent, errorMessages)
		}
	}
	return buffer, nil
}
// body returns the content as body data depending on
// the content type.
body returns the content as body data depending on
the content type.
// body returns the content as body data depending on // the content type .
func (p *Parameters) body() (io.Reader, error) {
	buffer := bytes.NewBuffer(nil)
	if p.Content == nil {
		return buffer, nil
	}
	switch p.ContentType {
	case rest.ContentTypeXML:
		tmp, err := xml.Marshal(p.Content)
		if err != nil {
			return nil, errors.Annotate(err, ErrProcessingRequestContent, errorMessages)
		}
		buffer.Write(tmp)
	case rest.ContentTypeJSON:
		tmp, err := json.Marshal(p.Content)
		if err != nil {
			return nil, errors.Annotate(err, ErrProcessingRequestContent, errorMessages)
		}
		buffer.Write(tmp)
	case rest.ContentTypeGOB:
		enc := gob.NewEncoder(buffer)
		if err := enc.Encode(p.Content); err != nil {
			return nil, errors.Annotate(err, ErrProcessingRequestContent, errorMessages)
		}
	case rest.ContentTypeURLEncoded:
		values, err := p.values()
		if err != nil {
			return nil, err
		}
		_, err = buffer.WriteString(values.Encode())
		if err != nil {
			return nil, errors.Annotate(err, ErrProcessingRequestContent, errorMessages)
		}
	}
	return buffer, nil
}
func ( p * Parameters ) body ( ) ( io . Reader , error ) { buffer := bytes . NewBuffer ( nil ) if p . Content == nil { return buffer , nil } switch p . ContentType { case rest . ContentTypeXML : tmp , err := xml . Marshal ( p . Content ) if err != nil { return nil , errors . Annotate ( err , ErrProcessingRequestContent , errorMessages ) } buffer . Write ( tmp ) case rest . ContentTypeJSON : tmp , err := json . Marshal ( p . Content ) if err != nil { return nil , errors . Annotate ( err , ErrProcessingRequestContent , errorMessages ) } buffer . Write ( tmp ) case rest . ContentTypeGOB : enc := gob . NewEncoder ( buffer ) if err := enc . Encode ( p . Content ) ; err != nil { return nil , errors . Annotate ( err , ErrProcessingRequestContent , errorMessages ) } case rest . ContentTypeURLEncoded : values , err := p . values ( ) if err != nil { return nil , err } _ , err = buffer . WriteString ( values . Encode ( ) ) if err != nil { return nil , errors . Annotate ( err , ErrProcessingRequestContent , errorMessages ) } } return buffer , nil }
body returns the content as body data depending on
the content type.
body returns the content as body data depending on the content type .
// Process content based on content type.